Hi everyone i have a rpi 2 B+ and im using a relay to close the circuit between GPIO 3 and GROUND (it does the rpi start when its off and rpi shutdown when its on) but im confused because the GPIO3 is switching between HIGH and LOW alone, my python script to shutdown is
Code: Select all
import RPi.GPIO as GPIO
import time
import os
GPIO.setmode(GPIO.BCM)
GPIO.setup(3, GPIO.IN, pull_up_down = GPIO.PUD_UP)
def Shutdown(channel):
os.system("sudo shutdown -h now")
GPIO.add_event_detect(3, GPIO.FALLING, callback = Shutdown, bouncetime = 2000)
while 1:
print("waiting");
time.sleep(1)
when i run python script.py my pc immediatle shutdown, so i commented the line os.system("sudo shutdown -h now") and wrote print ("HIGH"), so i got a lot of HIGH even though I was not doing anything (relay is OPEN), is that a bug ? im really newbie on eletronic
Thank you