Shop OBEX P1 Docs P2 Docs Learn Events
LED display - Hex to decimal question — Parallax Forums

LED display - Hex to decimal question

Steve2381Steve2381 Posts: 94
edited 2006-04-13 19:05 in BASIC Stamp
Hello

Just started programming with the Stamps - so please bear with me!
I have this line in my program displaying a clock...

DEBUG CRSRXY, 0,1,HEX2 Hours,":",HEX2 Minutes,":",HEX2 Seconds,":",DEC2 Tenths," ",CR·
The hour, minute and second variables are hex numbers.

Later in the program I have a list of the following·statements (with different variables)·controlling the LED displays....

SHIFTOUT Time_data,Time_clock,MSBFIRST,[noparse][[/noparse]6]·· 'Select 6th digit position
SHIFTOUT Time_data,Time_clock,MSBFIRST,[noparse]/noparse][color=red]Seconds DIG 0[/color······· 'Send the digit
PULSOUT Time_load,5

My problem is I need to convert the variable I have highlighted in red to a·decimal value, as it is still in hex format and therefore not displaying correctly on the LED display.

Any ideas?

Many thanks

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-04-12 23:19
    I'm going to go out on a limb here and guess you're using the MAX7219?· You didn't say what device you're sending the data to.· If it is in fact the MAX7219 though you can send the low nibble and it will work fine.· BCD values are essentially two decimal digits packed into a byte.· So if you send the low nibble and the high nibble separately you will have both digits.· The following link includes code which shows how to do this.

    http://forums.parallax.com/showthread.php?p=552892

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • Steve2381Steve2381 Posts: 94
    edited 2006-04-13 19:05
    Ok - thanks for the link, I will have a look.

    (Yep - it is a Max chip.... excellent bit of kit)

    Cheers, Steve
Sign In or Register to comment.