show a nuber on leds
marcla
Posts: 19
hello!
I want to show an number on 4 leds using bcd code.
how do i do it?
is ther any cod that i can giv a nuber Ex. 5 an di shows it on my leds.
Ex. 5 should lock like this:
PIN········ 16···· 17···· 18···· 19·· (Pin on the propeller)
Number··· 1······ 2····· 4······ 8··· (In the binary system)
Status···· high·· low···high···low· (Led Status)
I want to show an number on 4 leds using bcd code.
how do i do it?
is ther any cod that i can giv a nuber Ex. 5 an di shows it on my leds.
Ex. 5 should lock like this:
PIN········ 16···· 17···· 18···· 19·· (Pin on the propeller)
Number··· 1······ 2····· 4······ 8··· (In the binary system)
Status···· high·· low···high···low· (Led Status)
Comments
a "DIRA[noparse][[/noparse] 19..16 ] := %1111" will set pins 16 through 19 to output mode and a "OUTA[noparse][[/noparse] 19..16 ] := BCD"
will set the pin states to the least significant 4 bits of BCD. In Spin, you can give a pin range with the
highest pin number first or the lowest pin number first. The first number is the most significant bit and
the last number is the least significant bit. Don't forget the current limiting resistors on the LEDs.
I have the bcd string in normal nubers ex. 5 not in BCD code so my problem is not the showing part it's how i decode ex. number 6 in to bcd format
Do that in a loop, and you have all digits in BCD.
Nick
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Never use force, just go for a bigger hammer!
The DIY Digital-Readout for mills, lathes etc.:
YADRO