PIC basic programming tutorial: In the following PIC tutorial i used books to learn fundamental knowledge about Embedded system. After that i install MikroC compiler and Proteus simulator tool to implement following basic PIC programming tutorial:
Interfacing of LCD with PIC: In this tutorial LCD is interfaced with PIC(PIC18F452) controller. If you want to learn more kindly see tutorial on youtube as well.
>> LCD interface with PIC C Code: #define RS PORTB.F0 #define E PORTB.F1
void cmd_lcd (unsigned char dat) // function to write command at lcd port { PORTD=dat; RS=0; //clear RS (ie. RS=0) to write command E=1; // send H-L pulse at E pin delay_ms(50); E=0; delay_ms(50); }
void data_lcd (unsigned char dat) // function to write data at lcd port { PORTD=dat; RS=1; // set RS=1 to write DATA E=1; // send H-L pulse at E pin delay_ms(50); E=0; delay_ms(50); }
void init_lcd() // function to initialize the LCD at power on time {
cmd_lcd (0x38); // 2x16 display select cmd_lcd (0x0c); // display on cursor off command cmd_lcd (0x06); // automatic cursor movement to right cmd_lcd (0x01); // lcd clear command cmd_lcd (0x80); // first row first coloumn select command }
void string_lcd(unsigned char *str) // function to display string to lcd { while(*str!='\0') // '\0' is null char as last char of pointer is null { data_lcd(*str); str++; } }