The objective of this tutorial is to develop a program interacting with Raspberry PI GPIO.
Prerequisites
Install RPi.GPIO
pip install RPi.GPIO
First program
This program just setup pin 12 as Output with initial value High. Then I toggle the value to Low. Finally, I toggle to initial value High.
#!/usr/bin/python
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BOARD)
GPIO.setup(12, GPIO.OUT, initial=GPIO.HIGH)
print(GPIO.input(12))
GPIO.output(12, GPIO.LOW)
print(GPIO.input(12))
GPIO.output(12, GPIO.HIGH)
print(GPIO.input(12))
See source here
Output:
1
0
1
See more here