Usr164
Posts: 1
Joined: Sun Jan 31, 2016 9:16 pm

Need some help with python script with button and if santanc

Sun Jan 31, 2016 9:19 pm

Hi guys. I made a script for my lights. Can you check the code and pleas tell me whats wrong because nothing happens when I click the button?


import RPi.GPIO as GPIO
import time

GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
GPIO.setup(21, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(18,GPIO.OUT)

while True:
input_state = GPIO.input(21)

if input_state == False and GPIO.output == 1:
print "1" and GPIO.output(18,0)

elif input_state == False and GPIO.output == 0:
print "1" and GPIO.output(18,1)
Last edited by Usr164 on Mon Feb 01, 2016 6:07 pm, edited 3 times in total.


Return to “Python”