Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use interrupt based GPIO #2

Open
bornskilled200 opened this issue Dec 31, 2014 · 0 comments
Open

Use interrupt based GPIO #2

bornskilled200 opened this issue Dec 31, 2014 · 0 comments

Comments

@bornskilled200
Copy link
Owner

https://github.com/g0to/misc_scripts/blob/master/raspi_gpio_actions_INT.py

import subprocess
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)

# GPIO3 (pin 5) set up as input. It is pulled up to stop false signals
GPIO.setup(3, GPIO.IN, pull_up_down=GPIO.PUD_UP)

# wait for the pin to be sorted with GND and, if so, halt the system
GPIO.wait_for_edge(3, GPIO.FALLING)
subprocess.call(['shutdown -h now "System halted by GPIO action"'], shell=True)

# clean up GPIO on normal exit
GPIO.cleanup()      
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant