Lights On

This primer will take you through the steps to learning how to control your CodeBot with Python. All you need is your CodeBot and a Chrome Web Browser.

Ready to get started? Open your browser to make.firialabs.com and let’s do this!

1. Turn on a User LED

Blinking an LED is often the first “Hello World” program for embedded devices like CodeBot. As a first step, let’s light one of the “User” LEDs in the center of the ‘bot.

Type the following into CodeSpace. Remember, you don’t have to type in the #comments.

# Very first CodeBot program - Lights ON!
from botcore import *

leds.user_num(0, True)

The code above uses the botcore module, which provides functions to control and monitor all the hardware on CodeBot. Take a look at the documentation for botcore.CB_LEDs.user_num to see how this function works.

2. A sequence of LEDs

Next try lighting more of the User LEDs, as shown below.

Note: to slow things down a bit, this code imports the time Python module. The function time.sleep adds a delay before each LED turns on.

from botcore import *
import time

leds.user_num(0, True)
time.sleep(1.0)
leds.user_num(1, True)
time.sleep(1.0)
leds.user_num(2, True)
time.sleep(1.0)
leds.user_num(3, True)