Im working on something similar these link: Connecting a Push Switch
But with few changes: LED attached and wish the LED to be high only when the switch is pressed.
I tried something like this, but the program does not run.
GPIO.setup(18, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) try: while True: input_state = GPIO.input(18) if input_state == True: GPIO.setup(18,GPIO.OUT) GPIO.output(18, True)
Should it not work if we just make high/up to low/down and make the switch to change it to high/up?