Using indicator leds on the Lego Brick
LED lights are commonly used in all electrical equipment to display status information. Your Lego brick is also equipped with an RGB led, that can be programmed to light up in different colors, and to blink according to various patterns. This LED is a great way to provide information for the user of a robot. This lecture is bout teaching you how to use this LED sensor in your robot control code.
- Lego Mindstorms EV3 Brick
- Ozeki 10 installed: http://www.ozeki.hu/index.php?owpn=6066
- Connect Brick via Bluetooth: http://www.ozeki.hu/index.php?owpn=6065
- Lego connection installed: http://www.ozeki.hu/index.php?owpn=6067
Video tutorial: 'How to use the Lego Status Light in Ozeki 10'
Start Control Panel through any browser!
Make sure to use the IP address of your Ozeki server in any webbrowser through the 9505 port, login to Ozek 10 and open the Control Panel from the desktop GUI. For this step it is assumed that your Brick is already paired through Bluetooth, if not please pair it with the following useful tutorial: http://www.ozeki.hu/index.php?owpn=6065. You should know that the Control Panel is capable to manage the message routing of all connections added to Ozeki 10, including the Brick Status Light.
Figure 1 - Starting the Control Panel through the desktop GUI
Select 'LED_1' from the list!
If the Brick is connected to Ozeki 10, all available connections will appear (Figure 2). If the Brick devices are missing from the list, the following short guide should help you connect them: http://www.ozeki.hu/index.php?owpn=6067. You will find 'LED_1' appear on the connection list with a 'Details' button to the right. By clicking it, you will find yourself on the device chat window of the LED.
Figure 2 - This is how you can see the detected LED_1 device
Send color command to the LED using chat!
On the chat interface, please send 'help' to list all available commands for the Brick LED (Table 1). Start by changing the color you wish the LED to glow. You can choose from green, red or orange. Orange was used for this series. It's fine if you get here because you are just only one step away to be able to use the LED. Send 'orange' command, so you can see the Brick LED glow (Figure 3).
Figure 3 - Change LED to orange
Send flash command to the LED using chat!
By flashing the LED, you will see it glow for a certain amount of time, then keep itself turned off for the same short period. Create this with a simple 'orangeflash' command (Figure 4), so it will start flashing. You can try 'greenflash' and 'redflash' too. It is a good idea to write short Ozeki 10 codes for your robot. This way you can visually create different robot LED states. Try bulding codes later on.
Figure 4 - Flash LED in orange
Send pulse command to the LED using chat!
A pulsing LED consists of 2 flashes and a longer off period and then 2 flashes again. Make a colorful orange pulse by sending 'orangepulse' (Figure 5). You have probably noticed that you didn't had to subscribe to the LED (from STEP 3 to 5), because the LED is not designed to send outgoing messages. The Brick LED is simply an input device accepting commands to emit light.
Figure 5 - Pulse LED in orange
Check the events of the LED!
Finally you can turn the LED using 'off' command and click on the 'Events' tabpage on the top of the Lego LED panel. In Ozeki 10 each device has an event list. Here you can check the history of the LED communication. It shows all 4 LED commands that were sent from the Ozeki 10 user (Figure 6) towards the LED. These commands can be easily understood and will be described on the table just below the screenshot. If you do not remember what your device did, you can always check the event history. On the Control Panel you can find a common event page to see all events.
Figure 6 - See the Lego Mindstorms EV3 Brick's Status Light events
The Brick Status Light command set
The text commands were created for the Lego LED to effectively use it from Ozeki 10. These tables contain all commands to control the Status Light. These messages can be sent through chat by yourself if you click on the 'Send' button or route commands from any other Ozeki 10 connection. You can control the LED simply from other services or devices, like e-mail, SMS or Snap codes.
|off||turn off the LED|
|green||set LED color to green|
|red||set LED color to red|
|orange||set LED color to orange|
|greenflash||set color to green and flash LED|
|redflash||set color to red and flash LED|
|orangeflash||set color to orange and flash LED|
|greenpulse||set color to green and pulse LED|
|redpulse||set color to red and pulse LED|
|orangepulse||set color to orange and pulse LED|
Commands Table - Commands controlling the Status Light
|help||request the command set|
|subscribe||subscribe to device messages|
|unsubscribe||unsubscribe from device messages|
|subscribers||shows the list of subscribers|
Basic commands Table - General commands for all devices
- The touch sensor and sensor messaging
- Capturing infrared signals using the IR sensor
- How to measure light intensity and how to capture color information
- Using motors and rotary encoders
- Distance measurement, the ultrasonic sensor
- Orientation in space, the gyroscope sensor
- Using the LCD display
- Power management and working with the brick battery
- Playing sounds on the Lego speaker