Advertisement
nbookham

pi_supply_soft_shutdown

Jul 7th, 2013
1,866
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.65 KB | None | 0 0
  1. # Pi Supply Soft Shutdown Script
  2. # Version 1.1
  3. # Nathan Bookham 2013
  4.  
  5. # Import the modules to send commands to the system and access GPIO pins
  6. from subprocess import call
  7. import RPi.GPIO as gpio
  8.  
  9. # Define a variable to store the pin number
  10. soft_shutdown_pin = 7 # Default pin for Pi Supply is 7
  11.  
  12. # Define a function to run when an interrupt is called
  13. def shutdown():
  14.     call('halt', shell=False)
  15.  
  16. gpio.setmode(gpio.BOARD) # Set pin numbering to board numbering
  17. gpio.setup(soft_shutdown_pin, gpio.IN) # Set up pin 7 as an input
  18.  
  19. gpio.wait_for_edge(soft_shutdown_pin, gpio.RISING) # Wait for input from button
  20.  
  21. shutdown() # Run the shutdown function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement