This page provides quick and easy tutorials to get started with Luos prototyping boards.
In the following example, we will make a LED turn on and off by pushing and releasing a button. You will need the following boards and accessories:
To begin, you have to install Python and Pyluos library, following the pyluos documentation page.
Plug together all the boards with cables. You can plug them to any of the two connectors of each board, in any order.
Warning: Don't close a loop with the boards at each extremity.
From left to right: LED, Button, and USB . The plug order doesn’t matter.
Plug the USB board to a computer with micro-USB to USB cable.
In this particular example there is no high consumption component so we can use the power given by USB.
Your device is now powered and connected. All the low-level code and electronics is ready to use to help you program your own behaviors.
The USB node handle a specific module called "Gate". There are other boards hosting "Gate" module and using different connection than USB. These particular modules convert Luos modules data into something easier to understand and manage, using JSON API.
Interacting with the Luos system and program behaviors will require to spot the USB connection on your computer. The following steps are explained on the General board use page with more details. In the following example, the associated port is
Once you know the port, you can connect using:
import pyluos from pyluos import Device device = Device('COM13')
When Pyluos establishes the connection with a Gate module, it asks to run a network detection. This detection allows to discover all boards wired together on the network.
To list the discovered boards you can run:
In this tutorial, Python should find three boards, the Gate (USB), the LED, and the Button boards. You can check that all are detected:
------------------------------------------------- Type Alias ID ------------------------------------------------- Gate gate 1 Button button_mod 2 Led rgb_led_mod 3
Knowing the alias of the boards, you can use them in your code. To read values from a sensor, you just have to read a variable. For example, you can see the button state using this code:
Python will answer
True if you execute this line by pressing the button and
False if you don't.
The same way, you can control a board by setting variables. In the following example we can control the led color using RGB values. Type and execute the following line:
device.rgb_led_mod.color = [50,80,5]
The LED turns on.
Changing to the value
[0, 0, 0] will turn it off.
More details are provided on the page Luos boards general use.
You can now write a simple behavior that makes the LED to turn on when pushing the button and turn off when releasing it.
# Import libraries from pyluos import Device # Establish connection with the luos network device = Device('COM13') # Use an infinite loop to put the behavior inside while 1: if (device.button_mod.pressed == True): # if the button is pushed device.rgb_led_mod.color = [0,15,15] # Assigns a color to the LED else: # If the button is released or idle device.rgb_led_mod.color = [0,0,0] # Turns the LED off
Test your behavior by executing the code.
The following video shows a basic tutorial explaining how to make a LED and a servomotor be responsive to a potentiometer.
These were simple tutorials to get you on tracks.
Now you just have to create awesome projects and share them with the community.