I have been covering quiet a few tutorials on using Orange Pi Zero and now we will see how to control GPIO pins and run a helloworld blink LED program using python. The Orange Pi Zero comes up with a 2X13 pin slot very similar to Raspberry Pi style pinout. It does not come presoldered and we need to solder it ourself.
The below links are part of my affiliate links
Orange Pi Zero
and a soldering iron if you dont have one.
Orange Pi Zero
Female header connector
I soldered the female header instead of a male header pin since its very easy to handle with prototyping just like Arduino.
I have drawn the pinout just similar to the above pic
I have listed the GPIO Pins out of these pinout
Logon to your Orange Pi Zero as root user using Putty or SSH client. and then run the below command to fetch and install the code
git clone https://github.com/duxingkei33/orangepi_PC_gpio_pyH3 cd orangepi_PC_gpio_pyH3 python setup.py install
Now I will show you how to control the RGB LED using Orange Pi Zero.
For that you need an RGB Led, or bunch of single colored LEDs or a breakoutboard like
this will also do.
If you are building your own RGB led circuit you will need three 220Ohms resistor and an RGB LED
I am going to use Pin 6 for GND, Pin 3 (PA12), Pin 5(PA11), Pin 7(PA06) for GPIO pin
to control the individual colors. I modified the blink_led.py from the repository.
#!/usr/bin/env python """Basic blinking led example. """ import os import sys if not os.getegid() == 0: sys.exit('Script must be run as root') from time import sleep from pyA20.gpio import gpio from pyA20.gpio import port __author__ = "Stefan Mavrodiev" __copyright__ = "Copyright 2014, Olimex LTD" __credits__ = ["Stefan Mavrodiev"] __license__ = "GPL" __version__ = "2.0" __maintainer__ = __author__ __email__ = "email@example.com" led = port.PA12 led1 = port.PA11 led2 = port.PA6 gpio.init() gpio.setcfg(led, gpio.OUTPUT) gpio.setcfg(led1, gpio.OUTPUT) gpio.setcfg(led2, gpio.OUTPUT) try: print ("Press CTRL+C to exit") while True: gpio.output(led, 1) sleep(0.1) gpio.output(led, 0) sleep(0.6) gpio.output(led1, 1) sleep(0.1) gpio.output(led1, 0) sleep(0.6) gpio.output(led2, 1) sleep(0.1) gpio.output(led2, 0) sleep(0.6) except KeyboardInterrupt: print ("Goodbye.")
Check out my other Orange Pi Tutorials for more information