Mar-22-2018, 07:26 PM
I currently have a 4x4 keypad working with this Python code. The script just runs indefinitely and I don't know how to get it to stop. I'm trying to get it to run only 4 inputs. Also to set a 4 digit password and then to pick it up and 'unlock'.
I also need a servo code to run after I get a correct password moving it to an 'unlocked' position. The servo code only moves the servo once and I would like it to move back to the original 'locked' position.
I have novice to near non-existent level skill with Python. I have pulled open sourced code from various website and modified them slightly to fit my Pi, keypad , and servo.
What do I need to add/delete?
Do I need a whole new code?
If you are gracious enough to help me could you include as much information as you can and thank you.
Keypad code
I also need a servo code to run after I get a correct password moving it to an 'unlocked' position. The servo code only moves the servo once and I would like it to move back to the original 'locked' position.
I have novice to near non-existent level skill with Python. I have pulled open sourced code from various website and modified them slightly to fit my Pi, keypad , and servo.
What do I need to add/delete?
Do I need a whole new code?
If you are gracious enough to help me could you include as much information as you can and thank you.
Keypad code
import RPi.GPIO as GPIO import time GPIO.setmode(GPIO.BOARD) MATRIX = [ [1,2,3,'A'], [4,5,6,'B'], [7,8,9,'C'], [0,'F','E','D'] ] COL = [7,11,13,15] ROW = [12,16,18,22] for j in range (4): GPIO.setup(COL[j], GPIO.OUT) GPIO.output(COL[j], 1) for i in range (4): GPIO.setup(ROW[i], GPIO.IN, pull_up_down = GPIO.PUD_UP) try: while(True): for j in range (4): GPIO.output(COL[j],0) for i in range (4): if GPIO.input (ROW[i]) == 0: print (MATRIX[i][j]) while (GPIO.input(ROW[i]) == 0): pass GPIO.output(COL[j],1) except KeyboardInterrupt: GPIO.cleanup()Servo code
import RPi.GPIO as GPIO GPIO.setmode(GPIO.BOARD) GPIO.setup(11,GPIO.OUT) pwm=GPIO.PWM(11,50) pwm.start(5) pwm.ChangeDutyCycle(10)