Você está na página 1de 2

/*

* Relay_DCMotor.c
*
* Created: 1/4/2015 10:40:41 AM
* Author: User
*/

#include <avr/io.h>
#define F_CPU 8000000UL
#include <util/delay.h>

int main(void)
{
DDRC = 0xFF; //Port C as output
DDRA = 0x00; //Port A as input
PORTA = 0xFF; // Pull up Port A

while(1)
{
//TODO:: Please write your application code
if (PINA==0xFE)
{
PORTC = 0x01; //High output pin PC0
}
else if(PINA==0xFD)
{
PORTC = 0x02; //High output pin PC1
}
else
{
PORTC = 0x00; //reset Port C
}
}
}

/*
* Relay_DCMotor_LCD.c
*
* Created: 1/4/2015 12:03:38 PM
* Author: User
*/

#include<avr/io.h>
#define F_CPU 8000000
#include<util/delay.h>

#define LCD_DATA_PORT PORTB


#define LCD_CONT_PORT PORTD
#define LCD_RS PD0
#define LCD_RW PD1
#define LCD_EN PD2

#include<avr/lcd.h>
//#include<avr/adc.h>

int main(void)
{
DDRB=0xFF;
DDRC=0xFF;
DDRD=0x07;
DDRA=0x00;
PORTA=0xFF;

lcd_init();
/*LCD initialization*/

lcd_string_write(" MicroP&Interf");
/*String display in 1st row of LCD*/

lcd_command_write(0xc0);
/*Cursor moves to 2nd row 1st column of LCD*/

lcd_string_write(" Relay_DCM_LCD");
/*String display in 2nd row of LCD*/

_delay_ms(100);
_delay_ms(100);
//_delay_ms(500);
//_delay_ms(500);
/*Display stays for 2 second*/

lcd_command_write(0x01);
/*Clear screen*/

lcd_string_write("<<DC_MOTOR_MOV>>");
/*String display in 1st row of LCD*/

/*Start of infinite loop*/


while(1)
{
if (PINA==0xFE)
{
PORTC = 0x01; //High output pin PC0
lcd_command_write(0xc0); //*Cursor moves to 2nd row 1st column of LCD*/
lcd_string_write("-->>>M1_FWD_DIR!!"); //*String display in 2nd row of LCD*/
}

else if (PINA==0xFD)
{
PORTC = 0x02; //High output pin PC1
lcd_command_write(0xc0); //*Cursor moves to 2nd row 1st column of LCD*/
lcd_string_write("<<<--M1_REV_DIR!!"); //*String display in 2nd row of LCD*/
}
else
{
PORTC = 0x00; //reset Port C
lcd_command_write(0xc0); //*Cursor moves to 2nd row 1st column of LCD*/
lcd_string_write("###_M1_STOP_###"); //*String display in 2nd row of LCD*/
}
}
}

Você também pode gostar