+ Post New Thread
Results 1 to 3 of 3
  1. #1
    Advanced Member level 1
    Points: 2,876, Level: 12

    Join Date
    Mar 2015
    Posts
    458
    Helped
    3 / 3
    Points
    2,876
    Level
    12

    Ascii to BCD Conversion

    Hi all.
    I am making a simple project where i need to display the contains of Array to seven segment display.
    for ex.
    unsigned char array[4]={"1234"};
    also i have four seven segment displays where i need to display 1 to segment 1, 2 to segment 2, 3 to segment 3, 4 to segment 4.
    common anode segments are connected to PORT 1 of 89S52 Microcontroller.
    how can i do it. can anybody provide me some logics to do it.

    •   AltAdvertisement

        
       

  2. #2
    Super Moderator
    Points: 80,462, Level: 69
    Achievements:
    7 years registered
    Awards:
    2nd Helpful Member
    betwixt's Avatar
    Join Date
    Jul 2009
    Location
    Aberdyfi, West Wales, UK
    Posts
    13,183
    Helped
    4403 / 4403
    Points
    80,462
    Level
    69

    Re: Ascii to BCD Conversion

    No need to convert to BCD, just create a second array containing the bit pattern of segments and drive the port with it directly.

    hint: think of the segments as bits in the port, for example segment A = bit 0, segment B = bit 1 and so on. Then work out the bit pattern and hence numeric value for the segments you want lit for each digit.

    also i have four seven segment displays where i need to display 1 to segment 1, 2 to segment 2, 3 to segment 3, 4 to segment 4
    Be careful not to confuse segments and digits. A digit is the whole display module consisting of seven segments and maybe a decimal dot, a segment is the individual bar that makes up the shape of the digit.

    Brian.
    PLEASE - no friends requests or private emails, I simply don't have time to reply to them all.
    It's better to share your questions and answers on Edaboard so we can all benefit from each others experiences.



    •   AltAdvertisement

        
       

  3. #3
    Advanced Member level 4
    Points: 7,724, Level: 20

    Join Date
    Jan 2015
    Posts
    1,083
    Helped
    344 / 344
    Points
    7,724
    Level
    20

    Re: Ascii to BCD Conversion

    Also be aware that strings in most compilers are null terminated which mean that "1234" is actually 5 characters long.
    Susan



--[[ ]]--