Programming the Basics

Now that the F1 Starter Kit is connected to the Ctrl Cloud Platform, this tutorial covers how to program basic I/O on the F1 Starter Kit.

Light up the Onboard RGB LED

F1 Starter Kit RGB LED location

The F1 Starter Kit has an onboard, fully addressable RGB LED. You can set different colours and brightness levels.

  1. Open the CtrlR REPL terminal and type the following commands to experiment with the RGB LED:

    # Test RGB LED heartbeat
    rgbled.heartbeat(True)
    

    The RGB LED should now be pulsing.

    # Stop heartbeat and set a solid colour (R, G, B)
    rgbled.heartbeat(False)
    rgbled.color(0xff0000)   # Red
    rgbled.color(0x00ff00)   # Green
    rgbled.color(0x0000ff)   # Blue
    

Creating a project in CtrlR

  1. In a known destination on your computer, create a new project folder called RGB-Blink.

    Create RGB-Blink folder
  2. Launch VS Code and open the RGB-Blink project folder you created.

    Open folder in VS Code Select RGB-Blink folder
  3. Create a new file called main.py and add the following code:

    Create main.py file
    import time
    
    colours = [0xff0000, 0x00ff00, 0x0000ff]  # Red, Green, Blue
    
    while True:
        for colour in colours:
            rgbled.color(colour)
            time.sleep(1)
    

Uploading code to your F1 Starter Kit

You can test code on the F1 Starter Kit by choosing one of two options in CtrlR:

Run file on device

Run file on device button

This option sends the script to the F1 Starter Kit and runs it immediately. The script is not stored on the device and will not persist after a reboot. This is useful for testing.

Running file on device

Upload to device

Upload to device button

This option uploads the script to the F1 Starter Kit’s file system. The script will persist and run on boot. Use this when your code is ready for deployment.