Hi
Do you find the code below correct and do you think it can read values from Port 0? The keypad and 7-segment display don't need any kind of programming in MCU 8051 IDE. The segments of 7-segment display need LOW voltage in order to get activated. For example, in the linked video you can notice that all the segments turn on when "0" is moved into the Port 1 at the end of the code. I think there is some problem with the code and the code doesn't read the keypad's input. Kindly help me. Thank you.
Video: http://www.youtube.com/watch?v=8IsqWjMUaMQ
Do you find the code below correct and do you think it can read values from Port 0? The keypad and 7-segment display don't need any kind of programming in MCU 8051 IDE. The segments of 7-segment display need LOW voltage in order to get activated. For example, in the linked video you can notice that all the segments turn on when "0" is moved into the Port 1 at the end of the code. I think there is some problem with the code and the code doesn't read the keypad's input. Kindly help me. Thank you.
Video: http://www.youtube.com/watch?v=8IsqWjMUaMQ
Rich (BB code):
; Interface a numeric keypad to PORT 0 and display the entered decimal digits
; ,1-9, on a 7-segment display connected to PORT 1
org 0x0
Repeat:
mov P0, #0x0FF ;Port 1 is not an input port
mov A, P1 ;the contents of P1 are moved into A
CJNE A, #1, DigitIz2 ;if A=1, then this would mean entered digit was "1"
mov P1, #1 ;this will diplay "1" on 7-segment display
SJMP Repeat ;execution of the program repeats
DigitIz2:
CJNE A, #2, DigitIz3
mov P1, #2
SJMP Repeat
DigitIz3:
CJNE A, #3, DigitIz4
mov P1, #3
SJMP Repeat
DigitIz4:
CJNE A, #4, DigitIz5
mov P1, #4
SJMP Repeat
DigitIz5:
CJNE A, #5, DigitIz6
mov P1, #5
SJMP Repeat
DigitIz6:
CJNE A, #6, DigitIz7
mov P1, #6
SJMP Repeat
DigitIz7:
CJNE A, #7, DigitIz8
mov P1, #7
SJMP Repeat
DigitIz8:
CJNE A, #8, DigitIz9
mov P1, #8
SJMP Repeat
DigitIz9:
CJNE A, #9, DigitIz0 ;here digit "0" stands for an error
mov P1, #9
SJMP Repeat
DigitIz0:
mov P1, #0
SJMP Repeat
end