Menu
Microbots
0
  • Learn
    • Getting Started
    • Maker Builds
    • Education
  • Shop
    • Modules & Parts
    • Tools & Gears
    • Robots & Displays
  • About
    • Our Story
    • Reach Out
    • FAQs
  • Sign in
  • English
  • Your Cart is Empty
Microbots
  • Learn
    • Getting Started
    • Maker Builds
    • Education
  • Shop
    • Modules & Parts
    • Tools & Gears
    • Robots & Displays
  • About
    • Our Story
    • Reach Out
    • FAQs
  • Language

  • 0 0

CodeCell: Controlling the Onboard RGB LED

The onboard RGB LED on CodeCell can be controlled programmatically to display different colors based on your project's needs.

With CodeCell’s built-in function, you can set the LED color easily:

myCodeCell.LED(uint8_t r, uint8_t g, uint8_t b); 
  • r → Red component (0-255)
  • g → Green component (0-255)
  • b → Blue component (0-255)

This allows full RGB color control for your project's needs.

Adjusting LED Brightness

In addition to color control, you can also adjust the brightness of the onboard LED using the following function:

myCodeCell.LED_SetBrightness(uint16_t level); 
  • level → Brightness level from 0 (off) to 10 (maximum brightness)

By default, the brightness level is set to 7.

For example, to turn off the LED completely during normal operation, use:

myCodeCell.LED_SetBrightness(0); // Turn off CodeCell LED 

Note: Even with the brightness set to 0, the LED will still blink red when the battery is low, ensuring you don’t miss important power status alerts.

Example: Changing the LED Based on Proximity

In this example, the onboard RGB LED turns red when an object is detected within a certain range using the light sensor’s proximity detection.

#include <CodeCell.h>

CodeCell myCodeCell;

void setup() {
    Serial.begin(115200); // Set Serial baud rate to 115200. Ensure Tools/USB_CDC_On_Boot is enabled if using Serial
    myCodeCell.Init(LIGHT); // Initializes light sensing, including proximity
}

void loop() {
    if (myCodeCell.Run(10)) {
        // Runs every 100ms to check proximity
        uint16_t proximity = myCodeCell.Light_ProximityRead();
        
        // Check if an object is within range
        if (proximity > 100) {
            myCodeCell.LED(0xFF, 0, 0); // Set LED to Red when proximity is detected
            delay(1000); // Keep the LED on for 1 second
        } else {
            // No action if the object is out of range
        }
    }
}

Notes About the onboard LED

Remember that the onboard RGB LED is also used for battery and power status indication. When using myCodeCell.Run(), the LED may be overridden to reflect charging or battery conditions.

If you want to control the LED without interruptions, you may need to adjust how often myCodeCell.Run() is called or ensure your LED commands are applied after system updates.

Additionally, adjusting the brightness level can help manage the visibility of the LED in different environments, or turn it off completely during operation while still maintaining critical low-battery alerts.


  • Share:

Follow

Github

  • About
  • Software
  • Education
  • Contact
  • FAQs
  • Terms
  • Refund Policy
  • Privacy Policy

Join our Community ~ Be the first to know about new products and get exciting deals!

© 2026 Microbots.

★ Reviews

Let customers speak for us

53 reviews
Write a review
85%
(45)
4%
(2)
2%
(1)
4%
(2)
6%
(3)
21
49
G
CodeCell C6 Drive
Gerhard Weidenauer

Great board with many funktions in small space

User picture
L
MotorCell
Lennart Lange

Nice packaging, good follow up on the delivery, need to look up some online resources now for my first actual project wiht the cell

B
CodeCell C6 Drive
Brandon

Awesome product with great tutorials and example code

G
MotorCell
Gerald Kendrick

Very happy with my MotorCell. I'm incorporating it into a prototype project that will hopefully result in me needing a few more!

User picture
A
CodeCell C6 Drive
Anonymous

Great product! Having the IMU, motor driver, and battery management directly on the board is incredibly handy for quick prototyping. Love it!

Improvement ideas:
- using an ESP32 other than the C6 to get more cores. On a single-core chip, WiFi tasks often interfere with real-time applications.
- adding two more motor drivers (with a slightly higher current rating) would be awesome for drone projects!
- I know the compactness of the board is a huge selling point and really optimised, but exposing a few more pins would be great. With the motor drivers already occupying 4 pins, having only 4 GPIOs left can be tight for complex projects (though I’m nitpicking, I’m really pushing this board to its limits!).

123