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
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
6.11. PULSE WIDTH MODULATION: AUTOMATED FAN COOLING SYSTEM 175<br />
void LCD_init(void)<br />
{<br />
delay_5ms();<br />
delay_5ms();<br />
delay_5ms();<br />
// output command string to<br />
//initialize LCD<br />
putcommand(0x38); //function set 8-bit<br />
delay_5ms();<br />
putcommand(0x38); //function set 8-bit<br />
delay_5ms();<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 />
//putchar:prints specified ASC<strong>II</strong> character to LCD<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_5ms();<br />
}<br />
//*************************************************************************<br />
//performs specified LCD related command<br />
//*************************************************************************