Introduction: Sound Reactive (VU) Colour Changing Mason Jar Lamp

This is a simple yet elegant looking colour-changing frosted mason jar lamp that changes colour based on the surrounding music. The frostings on the mason jar diffuses the light from the RGB LED making it look very uniform and beautiful especially in the dark.

Step 1: Clean

Run a stream of hot water over the adhesive for about 3 to 5 minutes. The sticker should peel off very easily. The, scrub off the excess adhesive and let it dry on a piece of clothe.

Step 2: Spray

Lightly and evenly coat it with 3 layers of frosted spray paint. I have a more comprehensive guide on how to frost mason jars in this Instructable: https://www.instructables.com/id/How-to-Make-an-E...

Step 3: Solder

Solder the resistor onto the anode of the LED so it is more convenient to wire up. This also allows this project to go breadboard-less.

Step 4: Wiring

* Connect the ground pin of the RGB LED (the longest one) to the GND pin on the Arduino

* Connect the red LED pin of the RGB LED (the one at the edge right next to the longest one) to pin 5 on the Arduino.

* Connect the green LED pin of the RGB LED (the one at the centre next to the longest one) to pin 6 on the Arduino.

* Connect the blue LED of the RGB LED (the last one by process of elimination) to pin 9 on the Arduino.

Note that these pins numbers are very important as these are the PWM pins of the Arduino which is the only way we can control the individual brightness of each of these LEDs thus being able to light every colour in the visible spectrum.

Sound Detector

* Connect the VCC pin to 3.3V on the Arduino

* Connect the GND pin to the GND pin on the Arduino

* Connect the Envelope Pin to pin A0 on the Arduino.

Step 5: Code

//pin variables
const int redPin = 5;
const int greenPin = 6;
const int bluePin = 9;
const int soundPin = 0;
//variables for storing raw sound and scaled value
int sound;
int scale;
void setup()
{
 //start the serial port a@ 9600bps
 Serial.begin(9600);
 //set RGB pins to OUTPUT
 pinMode(redPin, OUTPUT);
 pinMode(greenPin, OUTPUT);
 pinMode(bluePin, OUTPUT);
}
void loop()
{
 //read and store the audio from Envelope pin
 sound = analogRead(soundPin);
 //map sound which in a quiet room a clap is 300
 //from 0 to 3 to be used with switch case
 scale = map(sound, 0, 300, 0, 3);
 //print values over the serial port for debugging
 Serial.print(sound);
 Serial.print("   ");
 Serial.println(scale);
 //switch case on scaled value
switch (scale)
{
//if 0 RGB = Blue
case 0:
   digitalWrite(redPin, LOW);
  digitalWrite(greenPin, LOW);
  digitalWrite(bluePin, HIGH);
  break;
//if 1 RGB = Green  
case 1:
  digitalWrite(redPin, LOW);
  digitalWrite(greenPin, HIGH);
  digitalWrite(bluePin, LOW);
  break;
//if 2 RGB = Yellow  
case 2:
  digitalWrite(redPin, HIGH);
  digitalWrite(greenPin, HIGH);
  digitalWrite(bluePin, LOW);
  break;
//if 3 RGB = Red
case 3:
  digitalWrite(redPin, HIGH);
  digitalWrite(greenPin, LOW);
  digitalWrite(bluePin, LOW);
  break;
//default off
default:
  digitalWrite(redPin, LOW);
  digitalWrite(greenPin, LOW);
  digitalWrite(bluePin, LOW); 
  break;
 }
}

Step 6: Enjoy!

Enjoy your pretty little sound reactive lamp!

Comments

About This Instructable

501views

20favorites

License:

Bio: Aerospace Engineer working in Software Development with a passion for Hardware.
More by TechMartian:Flying Captain America's Shield - RC PlaneWide Angle ShotsLED Ping Pong With Shift Register
Add instructable to: