RGB LED
The WEMOS S3 MINI PRO includes an onboard
RGB LED that can display different colours by controlling its red, green and blue components.
The RGB LED uses:
-
- GPIO7 for RGB LED power control
1. Purpose of the RGB LED
The RGB LED is useful for learning:
-
- Modifying example programs
2. Hardware Connection
The RGB LED is already built into the S3 MINI PRO board, so no external wiring is required.
Its main connections are:
The power pin must be enabled before the LED can operate.
ESP32-S3
│
├── GPIO7 ───► RGB LED Power
│
└── GPIO8 ───► RGB LED Data
3. Controlling the RGB LED
A typical program begins by importing:
import s3minipro
from machine import Pin
The power line can then be enabled:
power = Pin(s3minipro.RGB_POWER, Pin.OUT, value=1)
Example:
s3minipro.rgb_led(255, 0, 0)
4. Understanding RGB Values
Examples:
s3minipro.rgb_led(255, 0, 0) # Red
s3minipro.rgb_led(0, 255, 0) # Green
s3minipro.rgb_led(0, 0, 255) # Blue
s3minipro.rgb_led(255, 255, 255) # White
s3minipro.rgb_led(0, 0, 0) # Off
5. Example: Cycling Through Colours
import time
import s3minipro
from machine import Pin
power = Pin(s3minipro.RGB_POWER, Pin.OUT, value=1)
s3minipro.rgb_led(255, 0, 0)
time.sleep_ms(500)
s3minipro.rgb_led(0, 255, 0)
time.sleep_ms(500)
s3minipro.rgb_led(0, 0, 255)
time.sleep_ms(500)
s3minipro.rgb_led(0, 0, 0)
power.value(0)
6. How the Program Works
-
- Disable power if required
7. Exercises
Possible exercises include:
-
- Functions for colour control
8. Possible Modifications
-
- Repeat sequences with loops
-
- Create smooth colour transitions
-
- Create custom colour functions
-
- Control the LED with push buttons
-
- Use the LED as a status indicator
-
- Combine the LED with the display or IMU
9. Programming Concepts Introduced
-
- RGB colour representation
10. Key Lesson
MicroPython Code
↓
GPIO Control
↓
RGB LED Hardware
↓
Visible Colour