21.08.2013 Views

Embedded Systems Design with the Atmel AVR Microcontroller Part II

Embedded Systems Design with the Atmel AVR Microcontroller Part II

Embedded Systems Design with the Atmel AVR Microcontroller Part II

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

8.2. WEATHER STATION 243<br />

delay(1);<br />

putcommand(0x38); //Function set 8-bit<br />

delay(1);<br />

putcommand(0x38); //Function set 8-bit<br />

putcommand(0x38); //One line, 5x7 char<br />

putcommand(0x0E); //Display on<br />

putcommand(0x01); //Display clear-1.64 ms<br />

putcommand(0x06); //Entry mode set<br />

putcommand(0x00); //Clear display, cursor at home<br />

putcommand(0x00); //Clear display, cursor at home<br />

}<br />

//*************************************************************************<br />

void putChar(unsigned char˜(c)<br />

{<br />

DDRC = 0xff; //Set PORTC as output<br />

DDRD = DDRD|0xC0; //Make PORTD[7:6] output<br />

PORTC = c;<br />

PORTD = PORTD|0x80; //RS=1<br />

PORTD = PORTD|0x40; //E=1<br />

PORTD = PORTD&0xbf; //E=0<br />

delay(1);<br />

}<br />

//*************************************************************************<br />

void putcommand(unsigned char˜(d)<br />

{<br />

DDRC = 0xff; //Set PORTC as output<br />

DDRD = DDRD|0xC0; //Make PORTD[7:6] output<br />

PORTD = PORTD&0x7f; //RS=0<br />

PORTC = d;<br />

PORTD = PORTD|0x40; //E=1<br />

PORTD = PORTD&0xbf; //E=0<br />

delay(1);<br />

}

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!