RGB "Flashlight"

My first ITP project, and first project for Intro to Fabrication is a flashlight. Originally, my idea was to build a "disco flashlight" that would cycle through multiple colors and play a 5-10 second disco sample. Unfortunately, the overhead for this proved to be complicated--none of the micro controller chipsets I own have enough processing power + storage to do this, and I didn't want to try to jam a Pi Zero in there. So I ultimately decided to stick with a simpler, multicolor flashlight. I plan to explore the sound processing capabilities of other micro controllers at a later date.

See the flashlight in action here, full breakdown below the break:

[video width="272" height="480" m4v="http://www.nickwallace.us/blog/wp-content/uploads/2017/09/IMG_0003.m4v"][/video]

Project Goals

Build a flashlight, which is defined as an object that:

  1. Creates light
  2. Is portable

Materials Used

  • Bike hand grip (junk shelf)
  • Pushbutton switch (junk shelf)
  • 9v battery & adapter
  • Arduino Nano clone
  • RGB LED (common cathode)
  • Resistors and wiring


After scouring the junk shelf, I found a bike grip, a pushbutton switch, and AA battery housing:

I decided that the bike grip would be a great base for the flashlight since it was literally designed to be held. I pencilled in a hole for pushbutton switch on the opposite side of the grip--the natural place where my thumb rested:

I used an expo knife to make a (really) rough cut. The rough cut would eventually be hidden by the pushbutton casing, so I didn't bother clean it up more:

Using the AA battery housing and a breadboard, I tested my RGB LED. A 220 ohm resistor is connected below:

Day 2: After realizing I would need a micro controller to make the circuit cycle through LED, I had to redo my design. I scrapped AA batteries in favor of a single 9V battery + hardness to power an Arduino Nano clone via Vin. Unfortunately, I didn't do a great job of documenting this change, so the next photo is of a fully breadboarded circuit with the updated design:

Testing out the breadboarded circuit:

[video width="640" height="360" m4v="http://www.nickwallace.us/blog/wp-content/uploads/2017/09/IMG_0002.m4v"][/video]

To move the circuit from the breadboard, I soldered resistors to the LED anode wires: 330ohm to blue and green (yellow wire) and 220ohm to red:

I then applied heat shrink tubing to the LED + resistor legs individually:

And I mounted the pushbutton in the grip:

And finally, I wired up all the components to the Nano clone:

It works!

[video width="272" height="480" m4v="http://www.nickwallace.us/blog/wp-content/uploads/2017/09/IMG_0003.m4v"][/video]


My arduino code is below. When you press the pushbutton, D2 of the arduino pulls HIGH, which triggers the LED in sequence R-G-B:

int button = 2; // pushbutton on digital pin 2
int state = 0; // variable for pushbutton status

// RGB LED color pin associations
int red = 5;
int green = 6;
int blue = 7;

void setup() {
  pinMode(button, INPUT);
  pinMode(red, OUTPUT);
  pinMode(green, OUTPUT);
  pinMode(blue, OUTPUT);

void loop() {
  state = digitalRead(button);

  // if button is pressed cycle through each color of the LED
  if (state == HIGH) {
    digitalWrite(red, HIGH);
    digitalWrite(red, LOW);

    digitalWrite(green, HIGH);
    digitalWrite(green, LOW);

    digitalWrite(blue, HIGH);
    digitalWrite(blue, LOW);
  } else {
    digitalWrite(red, LOW);
    digitalWrite(green, LOW);
    digitalWrite(blue, LOW);