Wednesday, October 22, 2008

MikroC "Hello World!" LCD example


Just an example of using MikroC to make a simple "Hello World!" PIC Microcontroller LCD project. The MCU is PIC16F877A (of course, it can be PIC16F887). The LCD display word "Hellow World!" on the first line and counting number on the second line. The image above is a screen capture of a simulation. I use the Proteus 7 VSM simulator to simulate my programs.

The source code in MikroC
//Test LCD
char *text = "Hello World!";
char mytext[3];
int i;
void main() {
// pic16f887
// ANSEL = 0x00; //Digital I/O for PORTA
// ANSELH = 0x00; //Digital Input for PORTB

// pic16f877A

CMCON = 0x07; //Set PORTA to Digital input
TRISB = 0; // PORTB is output
TRISA = 0x07; //PORTA as the input/output 0000 0111
i=0;
Lcd_Init(&PORTB); // Initialize LCD connected to PORTB
Lcd_Cmd(Lcd_CLEAR); // Clear display
Lcd_Cmd(Lcd_CURSOR_OFF); // Turn cursor off
Lcd_Out(1, 1, text); // Print text to LCD, 2nd row
while(1){
while(i<200){
IntToStr(i,mytext);
Lcd_Out(2,1,mytext);
Delay_ms(500);
i++;
}

i=0;
}

}


8 comments:

Anonymous said...

The mounts which are displayed here in the pics are good and also with good design like this only even I have found a company which is having LCD brackets according to TV/system model no and also he is having a great quality products. You Can get still more information about lcd t v wall bracket which I browsed on internet can fetch you help Another piece of advice would be to mount the bracket to a solid wall.

123brackets can be fitted to make efficient use of space in any room

Unknown said...

Interesting stuff I must admit. But what I really want to know is how did you really compose all this coding?? Okay, once I get this down hopefully it will work for me because I tried a couple different ways and none of them seemed to work. No worries though, that's why Google is here! haha I can literally find anything to everything on the web nowadays but enough of that.. But then thing is, that whenever I try inserting something like this it say, "The project type is not supported by this installation" How can I solve this problem?
Sony laptop lcd screen

Unknown said...

hey, i am new at this, so i wanted to ask if i wanted to implement a stop watch do i program the PIC and the LCD separately and can i connect the LCD to the PIC and print PORTB( for eg) on the screen?

Harry said...

Nazly 5oshi nami :p i dont think the lcd is programmable u just program the PIC to manage it
i dont get ur second question though sorry

DARK KNIGHT said...

can you provide the code for following functions
Lcd_Init(&PORTB)
Lcd_Cmd(Lcd_CLEAR)
Lcd_Cmd(Lcd_CURSOR_OFF)
Lcd_Out(1, 1, text)
IntToStr(i,mytext);
Lcd_Out(2,1,mytext);
Delay_ms(500);

SHIVENDRA MISHRA said...

Can you share the full of version of Proteus 7 VSM simulator please!

Unknown said...

can you tell me what is the name of lcd n what of size of that crystal?

Sujit said...

Can you please provide source code for lcd initialization.