RGB LED, surface-mount guide for the 37-in-1 Arduino Sensors Kit.
37-in-1 kit, module 08
KY-009: RGB LED, surface-mount
One LED package with red, green and blue elements you mix with PWM. Plug it in, upload the sketch, then change the thing it senses and watch the reading.
Module photo from the Joy-IT SensorKit documentation. The boards in the kit may not carry the Joy-IT print but are the same modules.
KY-009, RGB LED, surface-mount
One LED package with red, green and blue elements you mix with PWM.
How it works
RGB LED, surface-mount
What is going on
Three LEDs share one flat package. Each colour has its own pin, and analogWrite() sets how bright it is by switching it on and off faster than the eye can follow. Red, green and blue at full make something close to white; two at a time make yellow, cyan or magenta. The board has resistors fitted, so the pins go straight to the Nano.
Connections
Wiring to the Arduino Nano on its expansion shield
The pins below match the sketch further down this page; change one and change the other.
Power off first
Unplug the USB cable before you plug in, move or remove any module.
A lead plugged in live can touch the wrong pin for a moment, and 5 V on a signal pin is how a module dies. Unplug, wire, check the letters, then plug the cable back in.
Module pinGoes to
Module RS row of the column marked 9, digital bank
Module GS row of the column marked 10, digital bank
Module BS row of the column marked 11, digital bank
Module -G row, ground
The Nano I/O expansion shield supplied in the kit, photographed from above for the Voltaat product listing. Column positions measured from the photo; labels added by Fix It Today.
Where it plugs in on the shield
The ringed column is the one this module uses. G on top for ground, V in the middle for 5 V, S at the bottom for the signal. A module with more than one signal wire uses one column per wire.
Read the letters on the shield
Both banks on this shield read G, V, S from the top. The letters are printed at the ends of the rows.
The module's minus or GND pin goes to G, its plus or VCC pin to V, and each signal to the S row of the numbered column.
A module in backwards puts 5 V on the signal pin. Some survive it, plenty do not.
Starter sketch
Code you can copy and upload
Every sketch on these pages is compiled for the Arduino Nano before it is published. The pin numbers at the top match the connection table above.
ky009.inoArduino C++
1const uint8_t RED = 9, GREEN = 10, BLUE = 11; // PWM pins
2
3void setup() {
4 pinMode(RED, OUTPUT);
5 pinMode(GREEN, OUTPUT);
6 pinMode(BLUE, OUTPUT);
7}
8
9void show(int r, int g, int b) {
10 analogWrite(RED, r);
11 analogWrite(GREEN, g);
12 analogWrite(BLUE, b);
13 delay(700);
14}
15
16void loop() {
17 show(255, 0, 0);
18 show(0, 255, 0);
19 show(0, 0, 255);
20 show(255, 255, 0);
21 show(0, 255, 255);
22 show(255, 0, 255);
23 show(255, 255, 255);
24}
Try first
Change the three numbers in one show() line and see what colour you get.
The quickest way to see it respond.
1
Unplug the USB cable. Plug the module into the column shown above, minus to G, plus to V, signal to S.
2
Plug the USB cable back in. Copy the sketch, upload it, and open Tools > Serial Monitor at 9600 baud.
3
Do the thing the module senses and watch the reading, the L LED, or the sound respond.
Reference
More on this module
The Joy-IT page has the datasheet figures and examples for other boards; the repository has the original vendor files.
Have an idea for what MakerAccess should stock, improve, or explain next? Share it in the survey. If you bought or used a product and want to comment on the item itself, use the product feedback form.