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 with a 2 X 13 pins slot, very similar to Raspberry Pi style pinout. It does not come pre-soldered and we need to solder it ourselves.

Hardware required :

The below links are part of my affiliate links

Banggood links

Orange Pi Zero

https://www.banggood.com/Orange-Pi-Zero-H2-Quad-Core-Open-source-512MB-Development-Board-p-1110210.html?p=W214159476515201703B

Female header connector

https://www.banggood.com/5Pcs-40Pin-2_54mm-Female-Header-Connector-Socket-For-DIY-Arduino-p-945510.html?p=W214159476515201703B

and a soldering iron if you dont have one.

https://www.banggood.com/YIHUA-908D-220V-LED-Digital-Display-Soldering-Station-Soldering-Iron-Kit-p-1059873.html?p=W214159476515201703B

Amazon Links

Orange Pi Zero

http://amzn.to/2hTZOlN

Female header connector

http://amzn.to/2hkywrB

Connection :

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.

Log on 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

RGB LED:

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 breakout board like this will also do.

https://www.banggood.com/RGB-3-Color-LED-Module-For-Arduino-Red-Green-Blue-p-76519.html?p=W214159476515201703B

If you are building your own RGB led circuit you will need three 220 Ohms 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.

Code:

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__ = "support@olimex.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.")

Demo:

Check out my other Orange Pi Tutorials for more information.