Enough about Luos concept, you are here to actually build something and gets your hands dirty, right?

You will now learn to connect a L0 USB Gate with a L0 GPIO board connected to some LEDs and control the all thing via Python on your computer. Let's go!

On the previous page, we have shown you how to differentiate the two different L0 boards. For this part of the tutorial you will actually need one of each:

  • the led L0 GPIO board
  • the L0 USB Gate

Control LEDs

Setup the Led board

It's now time to do a bit of electronic and connect some LEDs to the board. To do that you will need:

  • three colored LEDs
  • three 560 Ω resitances
  • wires
  • plus a breadboard to make the setup cleaner

Once you have gathered everything, you can follow this wiring to setup your board:

L0 GPIO pinout

That should give you something like that:

L0 LED board

Setup the USB board

Now take the other L0: the USB Gate. Link it with the L0 with led LEDs using the specific cables. Now, plug the usb cable on the port on the other side of the Robus connectors:

L0 USB Gate

Now you can connect your USB Gate to your computer using a micro usb cable. All the steps are shown in the video below:

Luos network wiring animation

The power provided by your computer through the USB cable will power up all your Luos boards.

Note: The USB Gate actually chooses the higher power source between the power of your USB port and other possible power sources on the Luos network.

Ok now the hardware is ready. Let's jump to the software part!


Pyluos is a tiny Python library that was designed to let you easily interact Luos core. It exposes a clean and high-level API to make robotic development as simple as it should be.

pyluos hello world

Reminder: Luos Gates expose a JSON APIs that can be accessed via pretty much any programming language. As demonstration purposes we have written one in Python. Alternative in Scratch and Ruby already exist!

Install Pyluos

First you will need to have Python on your OS. Pyluos works with Python 2.7 and Python 3.4 or later.

On Linux and Mac OS you should already have one installed. Simply make sure that it is recent enough. You can install a specific version via your favorite package manager (yum, apt-get, brew, etc).

We highly recommend to use Python package manager pip for installing pyluos (see here for how to install it).

Once it's done, installing pyluos should be as easy as: pip install pyluos Depending on your Python installation you may need to run it via sudo: sudo pip install pyluos

pip install pyluos screencast

You can check that it works by running:

python -c "from pyluos import Robot"

Note: If you see something like this:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'pyluos'

Something wrong happened and please let us know on our forum or on the issues tracker so we can help!

Connect to the USB Gate

Now that pyluos is ready, make sure you have plugged your L0 USB Gate to your computer. The first thing we need is to find the serial id of your board. It can be a bit complex as it depends on your OS but thankfully pyluos comes with a command line utility that should do the trick! Run on your terminal command:

pyluos-usb-gate discover
> ['/dev/cu.usbserial-XXX']

You should see a list with the id of your connected board. Note this id somewhere, we will need it in a second!

On linux they should look like /dev/ttyUSBX or /dev/ttyACMX and on Windows COMX.

Note: This command line tool should have been automatically installed with pip install pyluos.

Ok, now we are ready to connect to our boards! It's actually pretty simple there is only two lines of codes that you can run on your favorite Python interpreter or as a script.

from pyluos import Robot

robot = Robot('/dev/cu.usbserial-XXX')

Note: You must replace /dev/cu.usbserial-XXX with the id you found on the previous step.

If everything went well, you are now officially connected to your L0 USB Gate! Next step, make it blink!

Turn LEDs On/Off

Now, you should have two L0 boards:

  • the one with the three LEDs built before
  • the USB gate

They should also be plugged together as shown previously.

If it's not the case make sure to unplug the L0 USB Gate from your computer to power it off, then connect the board with the led to the gate and finally reconnect the gate to your computer.

Note: On this first version we don't support hotplug. Thus, when connecting a new board you should always un-power and re-power the whole bus. This may change in the future to be simpler.

It's time to make every embedded developer dream come true, let's make some LEDs blink!

First, we connect to our board as we did before (you can skip this state if you are still connected):

from pyluos import Robot
robot = Robot('/dev/cu.usbserial-XXX')

Then we can ask for the found modules:

>[<"led_gpios": [<"p1" Input value="1632">, <"p2" Output state="low">, <"p3" Output state="low">, <"p4" Output state="low">, <"p5" Input state="low">, <"p6" Input state="low">, <"p7" Input state="low">, <"p8" Input state="high">, <"p9" Input value="2656">]>]

We can also access directly a module by using its name:


{'p1': <"p1" Input value="1651">,
 'p2': <"p2" Output state="low">,
 'p3': <"p3" Output state="low">,
 'p4': <"p4" Output state="low">,
 'p5': <"p5" Input state="low">,
 'p6': <"p6" Input state="low">,
 'p7': <"p7" Input state="low">,
 'p8': <"p8" Input state="low">,
 'p9': <"p9" Input value="1432">}

As you can see you directly get the value from all input pins. Actually they are automatically sync with the hardware but we will see this in more details in the next section.

You can also access the Output pins. For instance, to set the pin 2 to high, all you need to do is:


a led turn on, victory

And I'm sure you have already guessed it, to turn it off:


And last but not least to make it blink:

import time

freq = 2.0  # Hz

while True:
    time.sleep(1.0 / freq)

To get familiar with the API you can now try to make all three LEDs blink turn by turn. You can find my favorite solution here.

Led with a disco effect

On the next parts we will add some inputs and link them together!

results matching ""

    No results matching ""