PIC16F877 C Programming + LCD screen

Discussion in 'Embedded Systems and Microcontrollers' started by kevintcp85, May 16, 2007.

  1. kevintcp85

    kevintcp85 Thread Starter New Member

    Joined:
    May 16, 2007
    Messages:
    3
    Hello. I am a new member here. Currently I have carried out a group project with my classmates. I have two tasks, one is to create a PIC programming using C Program to display out some words in the LCD screen (2 lines). I plan to use PIC16F877. Another is to create a circuit (schematic diagram) for both PIC and LCD screen. I have found out some projects that quite similiar with what I want for my tasks. But, I have difficulties to understand especially for the programming part and I afraid my created circuit may not interface with my classmates' parts. For your information, my group project is car speed limit with voice recognition and the LCD screen is able to display out the words like 'Mode', 'Normal mode', 'Forward', 'Backward' etc. once the control button is pressed on the car controller. Transceiver and receiver are also used in this project. So, I hope I can get some information about the Programming code together with the schematic circuit, which can help me to get better understanding. Thanks. Urgently help.
  2. gootee

    gootee Active Member

    Joined:
    Apr 24, 2007
    Messages:
    443
    Location:
    Indiana, USA
  3. hgmjr

    hgmjr Moderator Staff Member

    Joined:
    Jan 28, 2005
    Messages:
    9,030
    Location:
    Tennessee, USA (GMT-6)
    Can you post a schematic of what you have so far so that our members can help you avoid any serious mis-steps?

    Here is a link that might be useful as you work through you coding to interact with the LCD. Section 4 in the linked to document has some examples of PIC LCD programs. Unfortunately, the program examples are in PIC assembly language. The examples can still provide insight into the logistics of programming the LCD if you are familiar with PIC assembly language.

    hgmjr
  4. kevintcp85

    kevintcp85 Thread Starter New Member

    Joined:
    May 16, 2007
    Messages:
    3
    Hello! Thanks for ur reply. Sorry to say that I do not have Assembly Language background so I plan to program the PIC in C Program. I afraid that I cannot finish my part for my group project as this is my first time of doing project. So, I hope I can get more information from you guys. For ur information, I have roughly layout the software flowchart and Gatt Chart so that they can help me in programming part. For the schematic circuit, I have found out some but I afraid that circuits that i have found may not interface with the programming. Preferable is circuit together with PIC programming in C Program. Hope will get reply from you guys.

    Thanks for ur sincere help.:)
  5. kanenas

    kanenas New Member

    Joined:
    Sep 4, 2010
    Messages:
    1
    Have a look at my website. I have written a code about lcd using pic184525.
    my code can be modified with an easy entry either 1 or 0 to cange from 8 bit to 4 bit. by changing to 4 bit and the pin numbers to suite a pic16f you can still use my code. my website is www.takismoschos.co.uk
    I am an amature but my code works.
  6. t06afre

    t06afre AAC Fanatic!

    Joined:
    May 11, 2009
    Messages:
    5,939
    First of all the best thing is to calm down. The first real world project may be scary. Use and combine what you have learned in previous classes. Good questions draw good answers. And regarding the information part I will say you are a little short. Like is the PIC only going to control the LCD or do it have other tasks also. If you have project description post it, I can not see any wrong in doing so. Also a schematic it can very well be hand drawn. Is 100 % mandatory
    Also your teacher is there to help. Teachers hate questions like "Help I do not understand anything" But if you do some research and compile a list with questions defining why and how you struggle. Your teacher will be more than happy to help. And the same will apply to this forum.
  7. elementalrage

    elementalrage Active Member

    Joined:
    Jul 30, 2009
    Messages:
    59
    First off, you sound like the kid who wants someone else to do their work for them. These guys hate that. They want you to provide something. They can't help you, if you're unwilling to do some work. You stated that you had a flowchart - you should have posted it. You should have also posted the schematic you found.

    I did the internet search for you.

    Here is a link for the PIC 16F877 and LCD screen in C language: http://www.mikroe.com/esupport/index.php?_m=knowledgebase&_a=viewarticle&kbarticleid=137&nav=0,63
  8. justshare

    justshare New Member

    Joined:
    Sep 4, 2010
    Messages:
    3
    #include<htc.h>
    #define col1 RD0
    #define col2 RD1
    #define col3 RD2
    #define RS RB4
    #define RW RB5
    #define E RB6
    __CONFIG(HS & PWRTEN &BORDIS &WDTDIS);



    unsigned char get_key(void)
    {
    unsigned char i,k;
    k=1;
    for(i=0;i<4;i++)
    {
    PORTD=0xFF;
    PORTD &=~(0x10<<i);
    if(!col1){return k;}
    if(!col2){return (k+1);}
    if(!col3){return (k+2);}
    k+=3;
    }
    PORTD|=(0x10<<i);
    return 0;
    }

    void init(void)
    {
    TRISB=0x00;
    TRISC=0x00;
    TRISD=0x0F;
    }



    void delay_TMR1(void)
    {
    TMR1L = 0x33;
    TMR1H = 0xF5;

    T1CKPS0 = 0;
    T1CKPS1 = 0;

    TMR1CS = 0;
    TMR1IF = 0;
    TMR1ON = 1;

    while(!TMR1IF){

    TMR1IF = 0;
    }
    }



    void delay_n(unsigned char n)
    {
    while(n>0)
    {
    delay_TMR1();
    n--;
    }
    }
    void LCD_Write_C(unsigned char value,int rs)
    {
    PORTC = value;
    RS = rs;
    RW = 0;
    E= 1;
    delay_n(1);
    E = 0;
    }


    void LCD_Write(unsigned char key,char rs)
    {
    unsigned char num[]={'x','1','2','3','4','5','6','7','8','9','*','0','#'};
    PORTC=num[key];
    RW=0;
    RS=rs;
    E=1;
    delay_n(1);
    E=0;
    }

    void main()
    {


    unsigned char key;

    init();

    LCD_Write_C(0x38,0);
    delay_n(250);
    LCD_Write_C(0x0C,0);
    delay_n(250);
    LCD_Write_C(0x01,0);
    delay_n(250);
    LCD_Write_C(0x80,0);


    while(1)
    {
    key=get_key();

    if(key!=0)
    {
    LCD_Write_C(0x01,0);
    delay_n(10);
    LCD_Write_C(0x38,0);
    delay_n(10);
    LCD_Write(key,1);


    }

    }
    Here is a program for interfacing the keypad with LCD.This might help u.
  9. retched

    retched AAC Fanatic!

    Joined:
    Dec 5, 2009
    Messages:
    5,198
    Location:
    Baltimore, MD
    This thread is from 2007.

    If he didn't turn in his homework yet, I think it is safe to say he failed.
  10. elementalrage

    elementalrage Active Member

    Joined:
    Jul 30, 2009
    Messages:
    59
    Ha! Good call! Glad I wasted my time....
Similar Threads
Forum Title Date
Embedded Systems and Microcontrollers xbee for pic16f877f programming using uart in mikrroc Oct 22, 2013
Embedded Systems and Microcontrollers Embedded C Programming for PIC16F877A book?. Nov 20, 2012
Embedded Systems and Microcontrollers Programming 4x20 lcd display with pic16f877a Aug 7, 2012
Embedded Systems and Microcontrollers ADC using c language programming and using PIC16f877a Feb 9, 2012
Embedded Systems and Microcontrollers Programming LCD + LDR in PIC16F877A Oct 8, 2011

Related Site Pages

Section Title

Share This Page