Orange Pi GPIO Control Using Python (Blink)
Update Repository
Make sure that your repository list is up-to-date or you can simply update it by running this command:
$ sudo apt-get install python3-dev python3-pip
Install Python 3 and PIP3
Please install python 3 if your device does not have any python 3 yet by using this command below:
$ sudo apt-get install python3-dev python3-pip
Install GPIO library for Python
$ sudo pip3 install --upgrade OPi.GPIO
Wiring the GPIO's PIN
Orange Pi Zero have 26 PIN GPIO with PIN layout as shows as the picture below
![]() |
Orange Pi Zero Pin Layout |
The program that we will run is a simple blink with a resistor and LED. Connect the Pi Zero's PIN number 12 (see pin layout above) to resistor 1K following to the LED's Anode (+) and the GND pin (number 6) to LED's Cathode (-)
Orange Pi Zero Wired to LED |
Create a Python script simple Blink
Create a new python file using vim or nano and save it as testBlink.py
import OPi.GPIO as GPIO import time GPIO.setmode(GPIO.BOARD) GPIO.setup(12, GPIO.OUT) try: print("Press CTRL+C to Exit") while True: print("HIGH") GPIO.output(12, True) time.sleep(1) print("LOW") GPIO.output(12, False) time.sleep(1) except KeyboardInterrupt: GPIO.output(12, False) print("Bye") finally: GPIO.cleanup()
From the script above, time.sleep(1) means that the program will hold for 1 second before continuing to the next step.
Run Script
Once you are ready, you can simply run the script by using this command below:
$ sudo python3 testBlink.py
Great Article
ReplyDeleteFinal Year Projects in Python
Python Training in Chennai
FInal Year Project Centers in Chennai
Python Training in Chennai