Part 2: Omega2 - Blink LED

If you have managed to successfully setup your Omega2 as described in Part 1 of this series, here is where the fun begins.

The goal when getting started on a new microcontroller system is to:
  1. get the controller to flash an LED,
  2. become familiar with the IDE, the Integrated Development Environment and the new MCU platform.

Step 1

The first thing we will do is connect an LED (Light Emitting Diode) to a GPIO (General Purpose Input/Output) pin on the microcontroller (MCU).

For this, we will need:
  1. solderless breadboard
  2. LED
  3. 1kΩ ¼W resistor
  4. male-male jumper cables or wire

This schematic (from Onion website) shows a 200Ω resistor instead of 1kΩ. Anything from 200 to 1kΩ is adequate for this experiment.

Photo (from Onion website) showing 200Ω ½W resistor (which will also work for this setup):

Step 2

Test that your LED circuit works. To do this, instead of connecting to GPIO0, drive the LED circuit from the 3.3V or 5V connection on the Expansion Dock. The LED should be lit. If the LED does not turn on, try turning the LED around in the circuit, i.e. reverse the connections to the LED.

Step 3

Test that the MCU is functional and can control the selected GPIO pin. To do this, connect to the Omega2 using your PC browser.


Using the Onion Console, click on the GPIO Tool icon.


Select the GPIO0 pin and set Direction to Output. Set Value to 1 and verify that the LED turns on.

Step 4 - Write a Python Script

Select the Editor icon from the Onion Console screen.

Enter the following code:

import onionGpio
gpio0 = onionGpio.OnionGpio(0)
value = 1
while 1:
   value = 1 - value
   count = 100000
   while count > 0:
      count -= 1
It is important that you enter the program exactly as shown. Indented lines are part of the control structure and must be indented as shown.

Save your file with an appropriate name such as in your directory named /root
Click on the Terminal icon to go back to the terminal screen. Log in to the Omega2 Linux.
If you are new to Linux you may want to spend some time exploring the Linux CLI (Command Line Interface).

Try the following commands. The text from = onwards is what the command does and is not to be entered.

pwd = print working directory
cd / = change directory to the system root directory (not the same as /root directory)
cd /root = change to directory named /root
= list the files in the current directory (You should see your program file
cat = view the contents of

Step 5 - Run the program


: When switching back and forth between the editor and the command line, pressing the up arrow Δ on your PC keyboard will recall the last command entered.

At this stage, if everything was done correctly, you should see the LED flash about twice every second.

To stop the program, type Ctrl-C.

Congratulations! You have successfully run your first program on the Omega2.

In Part 3, I will show how to use the serial UART (Universal Asynchronous Receiver/Transmitter) interface.

Blog entry information

Last update

More entries in General

More entries from MrChips

Share this entry