LCD and PIC16F877A interfacing

Discussion in 'Embedded Systems and Microcontrollers' started by clarelluffyjjang, Sep 7, 2017.

  1. clarelluffyjjang

    Thread Starter Member

    Jun 8, 2017
    34
    0
    hi i want to ask that if i want a counter that will count from 0 to 100 and display it on lcd. how should i start with the coding? i tried and it can count up one by one but its not in integers but its in the form of the picture i attached. i want it to display in integers like 1 then 2 3 4 5 till 99 how should i do?
     
    • ee.PNG
      ee.PNG
      File size:
      176.4 KB
      Views:
      19
  2. shteii01

    AAC Fanatic!

    Feb 19, 2010
    4,667
    745
  3. philba

    Active Member

    Aug 17, 2017
    959
    303
    I'm going to guess but I think you don't understand how numbers are displayed on your screen. The display needs to be given the character code for the digits, not the binary numbers. The code system is called ASCII though there are a number of different names (US-ASCII). The displays understand this so the code for a 0 needs to get sent to the display, not the actual 0. In a C/C++ program this is the distinction between the value 0 and '0'.
     
  4. upand_at_them

    Senior Member

    May 15, 2010
    248
    29
    Your loop may count from 0 to 100, but that number needs to be converted to ASCII characters to be displayed on the LCD. It will go something like this:

    1. Divide the number by 100 and get the integer. This is the hundreds place.
    2. Take the integer from step 1, multiply it by 100 and subtract that from your COUNT number.
    3. Divide this new number by 10 and get the integer. This is the tens place.
    4. Take the integer from step 3, multiply it by 10 and subtract that from the number at the end of step 2.
    5. This final integer is the ones place.

    Single digits get converted to the ASCII character by adding it to 48. Send each one to the LCD in the order you need.
     
Loading...