Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Pi Supply Soft Shutdown Script
- # Version 1.2
- # Nathan Bookham 2013
- # Stephen Longhurst 2013
- # Import the modules to send commands to the system and access GPIO pins
- from subprocess import call
- import RPi.GPIO as gpio
- # Define variables to store the pin numbers
- soft_shutdown_pin = 16 # Default pin for Pi Supply is 7
- keep_powered_pin = 18 # Default pin for Pi Supply is 8
- # Define a function to run when an interrupt is called
- def shutdown():
- # Cleanup GPIO
- gpio.cleanup()
- # Shutdown with halt and power off in 1 minute
- call(['shutdown', '-hP','+1'], shell=False)
- # Set pin numbering to board numbering
- gpio.setmode(gpio.BOARD)
- # Setup the input Pin to wait on
- gpio.setup(soft_shutdown_pin, gpio.IN)
- # Pin to pull high to keep the Pi Supply giving us power
- gpio.setup(keep_powered_pin, gpio.OUT, initial=gpio.HIGH)
- # Run the shutdown function
- shutdown()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement