7-segment LED display
In addition to digits from 0 to 9, there are some letters- A, C, E, J, F, U, H, L, b, c, d, o, r, t that can be also displayed by means of the appropriate masking.
Keypad configuration
' Example program to read keypad numbers and display with 7-segment
DEFINE OSC 20 ' using 20MHz clock oscillator
@ device hs_osc
row1 VAR PORTD.6 'declare ports
row2 VAR PORTD.5
row3 VAR PORTD.4
row4 VAR PORTD.3
col1 VAR PORTD.2
col2 VAR PORTD.1
col3 VAR PORTD.0
TRISD=%11111000 'assign ports
TRISB=0
loop:
Low col1:High col2:High col3 'column 1
IF (row1==0) Then 'if key 1 is pressed
PORTB=%1111001
Pause 1000
Else
PORTB=%1111111
EndIF
IF (row3==0) Then 'key 7
PORTB=%1111000
Pause 1000
Else
PORTB=%1111111
EndIF
IF (row4==0) Then 'key *
PORTB=%0111111
Pause 1000
Else
PORTB=%1111111
EndIF
High col1:Low col2:High col3 'column 2
IF (row1==0) Then 'key 2
PORTB=%0100100
Pause 1000
Else
PORTB=%1111111
EndIF
IF (row4==0) Then 'key 0
PORTB=%1000000
Pause 1000
Else
PORTB=%1111111
EndIF
High col1:High col2:Low col3 'column 3
IF (row1==0) Then 'key 3
PORTB=%0110000
Pause 1000
Else
PORTB=%1111111
EndIF
GoTo loop
End
You should try to write your own program for numbers "4", "5", "6" "8", "9" and symbol "#"......
No comments:
Post a Comment