triger script for relay in python (without cleanup)
Posted: Wed Jul 06, 2016 9:47 pm
Code: Select all
import RPi.GPIO as GPIO # import RPi.GPIO module
from time import sleep # lets us have a delay
GPIO.setmode(GPIO.BCM) # choose BCM or BOARD
GPIO.setup(14, GPIO.OUT) # set GPIO24 as an output
try:
while True:
GPIO.input(14) # set GPIO24 to 1/GPIO.HIGH/True
sleep(0.5) # wait half a second
GPIO.output(14, 1)
if GPIO.input(14):
GPIO.output(14, 0)
except KeyboardInterrupt: # trap a CTRL+C keyboard interrupt
GPIO.cleanup()but after i run program above, command cleanup turn switch off. How too end it without cleanup command ?
i'm begginer in raspberry and in pythone and try figure it out alone exit() quit() don't work maybe my whole idea is wrong ?
I have hope someone of You can help me and tell me if the idea of buttons on www are good ? maybe some article anything that can help me are welcome.