Arduino 003: Adjustable RGB Light

This will help you:

Learn to use a button, a potentiometer, and timed loops to control a colored light

Time: 1 hour / Level: B1

You should already:

You Will Need:

  • A computer

  • An Arduino

  • An A-to-B USB cable

  • A half-size breadboard

  • 1 RGB LED

  • 10k ohm potentiometer

  • Pushbutton switch (optional for on/off switch)

  • 2x 10k Ohm resistors

  • 3x 100-220 Ohm resistors (see this guide on resistors for LEDs)

Get the code and resources for this activity by clicking below. It will allow you to download the files from a Google Drive folder. Unzip the folder and save it in a sensible location.

Step 1: Color-Changing Light

Assemble the circuit as pictured in rgb_light.png. Open color_adjust.ino and read the code to understand what is going on. Here is a schematic of an RGB LED with an explanation for connecting it. Connect your Arduino and run the script. Try turning the potentiometer to adjust the color.

Step 2: On/Off switch

Open color_on_off.ino and read the code to understand what's going on. Connect your Arduino and run the script. Try pressing the switch to turn it on and off.

Step 3: Gradual Color Fading

Open color_gradual.ino and read the code to understand what is going on. In this script, the color automatically fades through the spectrum, and the potentiometer is used to set the speed of fading. Connect your Arduino and run the script. Try turning the potentiometer to adjust the color changing speed.

Step 4: Finishing Off

Take a video of your circuit in use, showing off a quick demo of the functionality. Share it via the button below to get it featured on the Circuit Board!

Return any parts to the supply area, and please sort things by the correct value so the next person can find what they need. Thanks!