I have one pipe where i have put the electricity cable and also a 2mm cable for the switch.
The switch is connected with to wires directly to the raspberry.
When i tested it on my desktop it worked file.
After conencting the switch in my garage the item returns the message 'Button Pressed' without stopping when switching...
What can i do?
See the attachment for how i connected it in test.
A drawing of how i connected it in the garage.
Code: Select all
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
GPIO.setup(18, GPIO.IN, pull_up_down=GPIO.PUD_UP)
while True:
input_state = GPIO.input(18)
if input_state == False:
print('Button Pressed')
time.sleep(0.2)