Reference

Last revision 2025/12/09

This document contains supplementary technical references for developing and debugging applications with Rainbow Ring V3.

API Description

SET_LED_RGB(LED, RED, GREEN, BLUE)
This function sets the RGB color for 1 specific LED. The value for the led should be between 0-11, indicating the 12 leds in the ring (in clock wise, the one on top of DFROBOT logo is LED 0). The red, green, and blue variable is the RGB value for that specific led. These values are intensity for each color from 0 – 64. For example:
set_led_rgb(2, 10, 15, 60);
Will set led 2 on the Rainbow LED Ring to the RGB value R=10 : G=15 : B=60.

SET_LED_UNICOLOR(LED, RGB, VAR)
This function changes 1 specific color for 1 specific LED. The rgb value should be 0 – 2, which represent the color RED, GREEN and BLUE. You can also use the "RED", "GREEN", or "BLUE" color enumerator. The var represent the intensity for the specific color. Take note that this function will not affect the intensity of other color on the same LED. For example:
set_led_unicolor(0, RED, 50);
This function change the red color intensity on LED 0 to 50.

SET_ALL_RGB(RED, GREEN, BLUE)
This function changes the RGB value for all LEDs. The red, green and blue variable is color intensity for RGB value for all LED.

SET_ALL_UNICOLOR(RGB, VAR)
This function changes 1 specific color for all LED. The rgb value should be 0 – 2 represent the color RED, GREEN and BLUE. The var is the intensity for the specific color.

ROTATE(COLOR, DIR)
This function will rotate 1 specific color for the LED ring to CW or CCW direction. The color variable is set from 0 – 7 (or you can use color enumerator, RED, GREED, BLUE, YELLOW, TURQUOISE, FUCHSIA, WHITE and BLACK. The dir variable is set from 0 – 2 (or the direction enumerator CW and CCW).

RANDOM_LEDS()
This function is to set a random LED(s) and random color on the LED ring. Each time this function is called, some LED will change color or lighten up randomly.

FADER()
This function is to perform a fader on all LED on the ring. After this function is called, all the LEDs will fade from zero intensity to full intensity and back to zero intensity (for all color).

FADER_HUE()
This function is to perform a color fader on all LED on the ring. After this function is called, the color on all LED will fade from Red to Green, Green to Blue and Blue to Red. The color for all LED remain RED after the function had ended.

Rainbow Ring Interaction -- I2C Connection

The following are the commands used to control your Rainbow ring. Included are the parameters needed and the terminal command to execute each command.

This sample code has been adapted from earlier Version 2 it has not been fully tested and may have some non-functioning commands, please let us know in the forum if you find problems with this sample code.

`#set_led_rgb(LED, INT, INT, INT);  //b     The first parameter is the LED number from 0-11, INT = intensity 0-64`
`#set_led_unicolor(LED, RGB, Int);  //u     RGB = 0, 1, OR 2.`
`#set_all_rgb(R, G, B);         //r     int = intensity  i.e.:RED 00, GREEN 25, BLUE 34: set_all_rgb(00, 25, 34);`
`#set_all_unicolor(RGB, Int);       //a`
`#rotate(color, dir);           //o     Color, direction, color is set from 0-7 and rotation from 0-2`
`#clearCommand();           //- No parameters needed`
`#random_leds ();           //x indicate how many LEDs to light and the delay between each`
`#fader ();             //f how many times to repeat`
`#fader_hue ();             //h how many times to repeat`
`#sequence();               //S how many times to repeat    *NOTE: CAPITAL S`
`#color_wave (0) ;          //w amount to increase ,delay`

Each terminal command should be preceeded by a "c" and ended with an "s". These commands are case sensitve.

EXAMPLE:co029901s

This will send the command (c) rotate(o) the color Blue (02) times (99) clockwise (01) send (s)

Please study the sketch, it has been commented to give you a better idea of the functionality.

Color Enumeration:

  1. RED
  2. GREEN
  3. Bgdgr
  4. YELLOW
  5. TURQUOISE
  6. FUCHSIA
  7. WHITE
  8. BLACK = OFF

rotate CW = 1, CCW= 2

Documents

Arduino sample code for v3
Rainbow LED Ring v3 bootloader

Was this article helpful?

TOP