Back

Here is how you code the Jewelbots LEDs

The LED class constructs objects that represent a single LED attached to the physical Jewelbot. There are 4 LEDs total that are connected to the Jewelbot.

COMPONENT INTIALIZATION

LED led; // Naming the variable type and then the name of variable.

In order to use the LED functions, you first need to initialize the library. This tells your program that you want to code around the LEDs, then you can use the functions below to do cool things with LEDs!

The different functions are called the "API", because they are the way you interact with the device. APIs are ways you can work with different interfaces, sometimes in a computer and sometimes online.

PARAMETERS

To activate a particular LED, you need to tell your program which LED you want to work with. In order to do that, you will use the values NE, NW, SE, SW. Those stand for the directions North East, North West, South East, South West.

There are also lots of different colors you can make your Jewelbots light up! The list of color names you can use are:

RED, GREEN, BLUE, MAGENTA, YELLOW, CYAN, WHITE, ORANGE, GOLD, PURPLE, PERIWINKLE, ROSE, OCEAN, and SKY.

API

.turn_on_single(LED_Pos led, ColorLabel color)

This function turns on a single LED of the Jewelbot.

LED led; led.turn_on_single(SW, GREEN);

.turn_on_all(ColorLabel color)

This function turns on all the LEDs on the Jewelbot.

LED led; led.turn_on_all(GREEN);

.turn_off_single(LED_Pos led)

This function turns off a single LED of the Jewelbot.

LED led; led.turn_off_single(NE);

.turn_off_all()

This function turns off all the LEDs on the Jewelbot.

LED led; led.turn_off_all();

.flash_single(LED_Pos led, ColorLabel color, uint8_t milliseconds)

This function turns on the LED for a set amount of time and then turns off.

LED led; led.flash_single(SE, BLUE, 1000);

.flash_all(ColorLabel color, uint8_t milliseconds)

This function turns on all the LEDs for a set amount of time and then turns them off.

LED led; led.flash_all(BLUE, 1000);