Saturday, 26 September 2015

Separate the data between # and * from serial receiver and display it on LCD(LM016L) in ATMEGA32L


#include <avr/io.h>
#include <util/delay.h>
void cmd(int);
void data(char);
int main(void)
{  
       char a;
int q,d;
        DDRB=0XFF;
DDRA=0XFF;
        DDRD=0xfe;
UCSRA=0x00;
UCSRB=0x18;
UCSRC=0x06;
UBRRH=0x00;
UBRRL=0x19;
cmd(0x38);
cmd(0x01);
cmd(0x0e);
cmd(0x06);
cmd(0x80);
    while(1)
    {
        while((UCSRA&0x80)==0);

a=UDR;
if(a=='*')
q=0;
if(q==1)
data(a);
if(a=='#')
q=1;

UCSRA=0x00;
    }
}
void cmd(int a)
{
PORTB=a;
PORTA=0x00;
PORTA=0x04;
_delay_ms(200);
PORTA=0x00;

}
void data(char s)
{
PORTB=s;
PORTA=0x01;
PORTA=0x05;
_delay_ms(200);
PORTA=0x01;
}

No comments:

Post a Comment