Customize 7 segment display

Status
Not open for further replies.

The Ponderer

New Member
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
 
Before you send a value to the 7-segment, you just test if it's less than 5.

That makes sense.

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.
 
i have one doubt.,am using pic 18F4431 for pwm generation.,i would like to display my dutycycle using 7 segment LED.,wt can i do to display dutycyle.
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…