I have a code that gets a one or a 0 from the user and will turn an LED on if 1, off if 0. It runs perfect when I run it in the Thonny IDE on the Pi itself. But when I try to run it through putty or even the Pi's terminal it will run everything except the if statements. (Does not print 'LED On/Off' or actually turn on or off the LED).
import RPi.GPIO as GPIO import time LEDPin = 17 #Setup def setup(): GPIO.setwarnings(False) GPIO.setmode(GPIO.BCM) #Set GPIO to BCM numbering GPIO.setup(LEDPin,GPIO.OUT,initial = GPIO.LOW) print('setup complete') def main(): setup() while 1: #check for keyboard input KBInput = input('1 for LED On, 0 for LED Off: ') if KBInput == '1': GPIO.output(LEDPin,GPIO.HIGH) print('LED On ') if KBInput == '0': GPIO.output(LEDPin,GPIO.LOW) print('LED Off ') try: main() except KeyboardInterrupt: print('\n\nGoodbye') GPIO.output(LEDPin,GPIO.LOW) GPIO.cleanup()