RGB LED/Using it, and when a colour is missing/09. When a colour is missing
Using it, and when a colour is missing · 09 of 9

When a colour is missing

A missing colour is nearly always a wire on a different pin from the sketch, or the cable one hole over. Wrong colours are crossed wires, steps that will not dim are a pin without PWM, and inverted colours are a sketch written for a common-anode part.

Five symptoms

When a colour is missing
The LED
Most often the sketch names a different pin from the one the wire is on, or a wire is one hole over. Counted from the square pad, RED is the fourth pin, GREEN the fifth, BLUE the sixth. A one-hole shift puts RED on an NC pin, which goes nowhere, and moves the others along. Then check every pin has its own pinMode.

Pick what the LED is doing. The ringed part of the board is where to look first, and the list beside it is the order to check in, by how often each is the answer.

One colour missing

The pin. Each of RED_PIN, GREEN_PIN and BLUE_PIN is a GPIO number, the one printed beside the pin on your board. It is not a count along the header.

One hole over. Count from the square pad: GND, NC, NC, RED, GREEN, BLUE. Shift the cable one hole and a colour lands on an NC pin, which is connected to nothing, and the others move along with it.

pinMode. Every colour pin needs its own pinMode(…, OUTPUT). Without it, on an Uno, digitalWrite(HIGH) turns on the pin's weak internal pull-up, which lights the LED so faintly you may not see it.

Wrong colours

You asked for red and got blue. Two wires are crossed, or the three numbers in the sketch are in a different order from the wires. The sketch in the first colour prints the name of each colour it means to show, which makes the swap obvious. Change the numbers in the sketch rather than the wires.

Only on or off

Every value between 1 and 254 looks like full or like off. The pin is not doing PWM. On an Uno only pins 3, 5, 6, 9, 10 and 11 can, and two libraries take pins away: Servo stops PWM on 9 and 10, and tone() interferes with 3 and 11. On the ESP32, the ESP32-S3 and the Pico every output pin can do PWM.

Everything inverted

Zero is bright and 255 is off, and red comes out green and blue together. The sketch was written for a common-anode LED and sends 255 - value. The TK02 is common cathode; what common cathode means has the detail. Remove the subtraction.

Pink, or dim, on a 3.3 V board

Normal. Green and blue get about 0.5 mA each from 3.3 V against red's 1.4 mA, so everything is dimmer and every mix leans red. Why 3.3 V turns it pink has the arithmetic and a second set of numbers for white.

When it does not work

How can I test the block without any code?

Wire GND to your board's GND and touch RED, GREEN and BLUE one at a time to its 3V3 or 5V pin. Each colour should light: the 1 kΩ resistor on the block keeps the current to a few milliamps even from a supply pin. If all three light, the block is fine and the problem is the sketch or the wiring.

Only one colour works, whichever pin I use.

GND is fine: without it no colour lights at all. A single working colour usually means the other two wires are on pins the sketch does not drive. Print the three pin numbers from the sketch and trace each wire from the square pad.

My Uno sketch also uses SPI, and blue misbehaves.

D11 is the Uno's SPI data pin, MOSI, and D10 is the default chip select. A sketch that also talks to an SPI device will fight the LED for them. Move GREEN and BLUE to pins 5 and 6, which are PWM pins too, and change the sketch to match.

Which ESP32 pins should I avoid?

On a classic ESP32, the pins used for flash memory, 6 to 11, and the input-only pins 34 to 39, which cannot drive an LED. Keep off the strapping pins too, the ones read at reset to choose how the chip boots. GPIO 25, 26 and 27 are free on the common ESP32 dev boards.

Where this goes next

The rest of the TinkerBlock blocks, and the sensors whose readings this LED can show as a colour.

Back to the blocks

Edit this page — content/books/rgb-led/when-a-colour-is-missing.mdx

Community

Questions about this product

See what other owners have asked, and read their solutions.

Ask a question ↗

RGB LED

Loading discussions…

Discuss this article

Ask about this page. The answer stays here, on the page it belongs to, for whoever hits the same wall next.

Browse Modules and blocks on the forum