If nothing is hooked up to a GPIO pin, does the OS read it as HIGH or LOW. I am trying to run a python script to shut down the Pi safely when a GPIO is set to high. With no GPIO pins connected, pin 2 is reading HIGH. Is this the normal behavior?
Code: Select all
import RPi.GPIO as GPIO import time import os GPIO.setmode(GPIO.BCM) GPIO.setup(2, GPIO.IN) GPIO.setup(23, GPIO.OUT) print("Shutdown script started. Wait for shutdown request") while True: GPIO.output(23, GPIO.HIGH) // sent HIGH to arduino - lets arduino know PI is running if(GPIO.input(2)): print("Request from button to shutdown") os.system("sudo shutdown -h now") break time.sleep(1)