Sep-23-2024, 11:00 PM
my messy and badly written code is to activate a 6 channel relay to open solenoids via the raspberry pi on my display cabinet.
it works, sort of. Iff the correct code is entered it opens and returns back to input question but when the correct code is entered again the program ends. I was wondering if maybe the input needed to be cleared before it asks again.
Hope your eyes don't bleed reading it but it was my first attempt at python code
it works, sort of. Iff the correct code is entered it opens and returns back to input question but when the correct code is entered again the program ends. I was wondering if maybe the input needed to be cleared before it asks again.
Hope your eyes don't bleed reading it but it was my first attempt at python code

import RPi.GPIO as GPIO # Import GPIO Module import time # just in case import os # just in case from time import sleep # Import sleep Module for timing GPIO.setmode(GPIO.BCM) # Configures how we are describing our pin numbering GPIO.setwarnings(False) # Disable Warnings OutputPins = [2, 3, 4, 17, 22, 27] # Set the GPIO pins that are required def start(): # create input and correct entry code print("") lock = input("Enter The Unlock Code: ") unlock = ["007"] # Set unlock code while lock not in unlock: # Check for correct input lock = input("Enter The Unlock Code: ") start() # Activate pins and relay for i in OutputPins: GPIO.setup(i, GPIO.OUT) GPIO.output(i, False) # Switch relay off time.sleep(10) for i in OutputPins: GPIO.setup(i, GPIO.OUT) GPIO.output(i, True) start() # return to input question