Hello all
I was wondering how to arrange coding so that only the digits 0,1,2,3 and 4 would be illuminated on a 7 segment display.
Digits 5,6,7,8 and 9 to be rejected (blank display).
Or have I missed something really obvious?
Thanks
Using the 'Select Case' command would be a good way to go if it's available. In pseudo code:
Code:
7seg = SomeVariable/10
PortB = Num
7seg = SomeVariable - 7seg*10
PortC = Num
Select Case 7seg
Case 1
Num = b'xxxxxxxx' ;Numeral 1 segments to turn on?
Case 2
NUM = b'xxxxxxxx' ;Numeral 2 segments to turn on?
...
...
Case 5
NUM = b'00000000' ;Numeral 5 segments all off
Case 6
NUM = b'00000000' ;Numeral 6 segments all off
....
....
end Select
Inline constants are ok for examples but not a good idea for real code. Use a style similar to this. It generates the same code but is easier to read an maintain.