Arduino Ladder · Bozoma Innovation Hub

Band 2  ·  Mood Lamp

Swap  Mood lamp on an RGB module

The whole colour story with three wires and no resistors, and an honest look at where the resistors went.

Time
85 min
You need
RGB LED module, 5 jumper wires (plus three 220Ω resistors if your module's back is bare)
At once
One per RGB module
Before this
Run id_02_which_rgb.ino first if you are not sure which RGB part you have. If you have a loose four-legged LED, build the core version first.

Sketches for this project

Every file opens with a plain-English header saying what it does and how to wire it, hole by hole.

Why

Where did the resistors go?

Band 2's core build uses a loose RGB LED with four legs, and you fit three resistors yourself: one per colour, because an RGB LED is three lights in one case and each needs its own.

The module is the same three lights on a small board, and it needs no resistors at all.

That is either a convenience or a lie, depending on whether you go and look. This build makes you go and look.

Which should you build?

You have a loose four-legged RGB LED

Build Band 2's core with that first. Wire the three resistors, get one backwards, fix it. Then come here afterwards if you want the comparison; it takes twenty minutes.

→ Core first, this second.

You only have the module

Then this is your Band 2, and it teaches the same things. What you would have missed is why the resistors are there, so the Look closer section makes you find them on the board and read their values instead of fitting them.

→ This page, and do the Look closer properly.

Not sure which you have? Run id_02_which_rgb.ino first. It also tells you which way round yours is wired, which you need either way.

Build

Three colour wires, five in all

20 min
+ − − + j i h g f e d c b a 1 5 10 USB ARDUINO UNO RGB module RGB module R R G G B B GND GND SCL SCL SDA SDA AREF AREF GND GND 13 13 12 12 11 11 10 10 9 9 8 8 7 7 6 6 5 5 4 4 3 3 2 2 1 1 0 0 IOR IOR RST RST 3V3 3V3 5V 5V GND GND GND GND VIN VIN A0 A0 A1 A1 A2 A2 A3 A3 A4 A4 A5 A5
Nothing of this module goes in the breadboard. The board is here for one thing only: the − rail the module's fourth pin returns to.
Before you startUSB unplugged. Clear the board.
Which rail pairYour board has two + rails and two − rails, one pair along each long edge, and on most boards the two pairs are not joined to each other. On this page, “the rail” always means the pair along the top edge, nearest row j, the same pair Band 2 uses. Put every rail wire on that pair and it works; split them across both and nothing lights, with nothing visibly wrong.

Turn the module over before you wire anything

Two kinds of RGB module are sold in the same kits and they look identical from the front. This takes ten seconds and it decides whether the next step damages your parts.

Three tiny black rectangles on the back, with numbers on them

The resistors are fitted. This is the common kind and the rest of this page assumes it.

→ Wire the three colour pins straight to the Arduino. Nothing of your own.

A bare back, nothing but solder

This module has no resistors. Wired straight to a pin and asked for 255, it would pull roughly five times what a pin is rated for, and it would damage the light and the pin together.

→ Put a 220 ohm resistor in each of the three colour wires, exactly as the loose LED needs. Then everything else on this page works unchanged.

If you cannot tell, fit the three resistors anyway. On a module that already has them the light is simply a little dimmer and nothing is harmed. When you are unsure, be wrong in the direction that costs you brightness rather than the direction that costs you the part.

Module pinArduino pinWhy this one
R9All three must have a ~ next to them. Without one you get off and full on and nothing between, which is Band 2's whole subject.
G10
B11
- or GNDthe − railIf your fourth pin is marked + or VCC, it goes to 5V instead and yours is the backwards kind.

Then one wire from the − rail to a GND pin. Five wires in all. The core build also takes five wires, so the module saves you no wiring at all: what it saves is the three resistors and the three careful placements that go with them. Worth noticing, because “a module is simpler” turns out to mean something narrower than it sounds.

Upload b2_05_rgb_module.ino and watch for a full cycle, which takes about twenty seconds.

You should seeA sunrise: black, then a dim red glow, then red over the lagoon, then orange, then full daylight held for a few seconds, then evening and back to night. Every change smooth, with no jumps.
If it lights but runs backwards, bright when it should be darkYou have the common-anode kind, and its fourth pin is already on 5V, which is where it has to be. That is the only reason it lights at all: with the shared pin on the − rail a common-anode part cannot light in any state, because the shared leg has to sit above the three colour legs for anything to flow.

So the wiring is already right and moving it cannot help. What is left is the numbers, and they really are upside down: 5V on the shared leg means 255 puts five volts on both ends of the light and gives you nothing, while 0 gives you full brightness. Change the three lines inside showColour:

analogWrite(redPin, 255 - r); and the same for green and blue.

Subtracting from 255 undoes exactly what the hardware did, and every number on every page then means what it says again. Band 2 Part 12 tells you the same two-part story: rewiring the shared leg to 5V is what makes it light, and it leaves 0 bright and 255 off.
If the colours are wrong but the fading is smoothYour module's pins are in a different order. Swap the wires at the Arduino end until red is red, then write down which pin is which.
If it snaps between colours instead of fadingOne of your three wires is on a pin without a ~. Check the printing on the board.
If nothing lights at allCheck the fourth pin. If it is marked VCC and you have it on the − rail, the module simply has no power, and that looks exactly like a dead part.

Make a diffuser, exactly as the core build asks: a ping pong ball, a sachet-water bottle, or folded white paper over the light.

You should seeA soft glow of one colour instead of a hard bright dot with coloured edges. This matters more than it sounds; an undiffused RGB LED does not look like a colour, it looks like three lights.
Look closer

Find the resistors

25 min

Turn the module over, or look closely at the front near the light.

You should seeThree small black rectangles, one per colour, with tiny numbers printed on them: often 101, 151, 221 or similar. They may be different values from each other.
If your module was the bare kindThen the three resistors you can read are the ones you fitted, all 220 ohm, and the questions below still work. Answer question 1 with “there were none, and I had to supply them”, and then answer the more interesting version: why would anybody sell a module without them, and who ends up paying for that decision?
Reading them

At this size they use three digits instead of colour stripes. The first two are the number and the third says how many zeros to add.

  • 101 is 10 with one zero, so 100 ohms. Stop at this one if you find it. With five volts on the pin and about two across a red light, 100 ohms lets through roughly 30 thousandths of an amp, and an Arduino pin is rated for 20. On this module all three colours run at once during the sunrise. It works, and it is over the line, and it is the same thing Band 1's traffic module page flags. Note it in your log and do not be surprised if the board runs warm.
  • 151 is 15 with one zero, so 150 ohms
  • 221 is 22 with one zero, so 220 ohms, the same value you would have used

Write down all three of yours. If they differ from each other, that is deliberate: red, green and blue LEDs do not need the same resistance to look equally bright, and whoever designed the board made a decision about it that you never got to make.

Questions for your log
  1. Your module needed no resistors. Where are they?
  2. If the three values on your board differ, why might that be?
  3. Comment out everything inside loop and put six lines there instead: showColour(255,0,0); then delay(2000);, and the same for green and blue. Upload and watch all three. Do they look equally bright to you? (If yours is the common-anode kind, use 0 where this says 255 and 255 where it says 0.) Put loop back afterwards.
  4. Name one thing you can do with the loose RGB LED that you cannot do with this module.
Something to check yourself against

1. On the module, soldered on, near the light. Turn it over and find them. They did not disappear and they were not made unnecessary: somebody fitted them for you, chose their values without asking you, and put the cost in the price of the board. That is what a module is. Every module you ever meet is a set of decisions somebody made on your behalf, and the useful habit is to go and find out what those decisions were.

2. A red LED lights at a lower voltage than a blue one, so with the same resistor the red would be much brighter. Different resistors even them out. That is a real design decision made on your behalf.

3. Probably not exactly, and blue often looks weakest. Your eye is not equally sensitive to the three colours either, so even perfectly matched LEDs would not look matched. This is why the white in your sunrise may look slightly pink or slightly blue, and why the core build's Part 12 mentions it.

4. Choose the resistor. Put the three colours in different places on the board. Use a different LED. Replace one that burns out. The module traded your choices for your time, and that is a good trade when you already know what you gave up.

Change it

Make it yours

40 min

The band's Make task is a colour story of your own, 45 to 90 seconds long, on a real place or a real thing. That does not change here. These are the smaller steps towards it.

Bronze
Make the six fades take exactly twice as long, without touching stepDelay. Leave the two delay calls that hold full day and full night alone; those are not fades. Then say what the two different ways of slowing a fade are, and what each one costs you.
Silver
Add a fourth colour to the story and a fifth fade, so the sequence tells a longer version of the same place. (If you have already done Band 4, do this instead: add a knob that sets the overall brightness without changing the colours, so the same story runs in a dark room. Multiply, do not add, and watch for whole-number division. You will need a potentiometer, which is not in this project's parts list.)
Gold
Write your story so that each fade's length is part of the description rather than fixed: give fadeTo a seventh value, how long that fade should take, and work the step delay out from it. Then a slow dawn and a sudden dusk are one line each.
Done

You still owe Band 2 the same evidence

To claim Band 2 you still need:

  • A video of your whole colour story, 45 to 90 seconds, not a short clip, with the diffuser on
  • Both testers' answers to what they thought it was showing
  • Your completed table from Part 8a
  • The six PWM pin numbers, written down
  • Your sentence about what you saw when you waved your hand
  • Your three resistor values off the module, and your answer to question 4
  • Your build log
  • Five or six correct answers in Part 11, the Check yourself questions, including question 6

Band 2 Part 7 says an RGB light needs three resistors and not one, and getting that wrong is one of the commonest mistakes in the band. You did not fit any. Answer it from what you found on the back of the board, and you will have understood it better than somebody who fitted three without ever looking at them.

Ship it

One video under sixty seconds, and one post of five lines. You built something different from the person next to you, so your video is the one nobody else in the room can post. Say in the post which build you chose and why — that choice is itself worth a line.

The four shots: three seconds of the thing still, fifteen of you doing something to it, fifteen of it responding all the way to the end, and ten of your measurement or the thing that went wrong first.

Show your work has the template and the three checks to make before anything goes public. Tag it #BozomaBuilds.