Sound Reactive (VU) Colour Changing Mason Jar Lamp
by TechMartian in Circuits > Arduino
2218 Views, 22 Favorites, 0 Comments
Sound Reactive (VU) Colour Changing Mason Jar Lamp
![VU LED Lamp](/proxy/?url=https://content.instructables.com/FE4/7EPI/J6WGEC57/FE47EPIJ6WGEC57.jpg&filename=VU LED Lamp)
![IMG_2504.jpg](/proxy/?url=https://content.instructables.com/FZY/JQ33/J6WGECYI/FZYJQ33J6WGECYI.jpg&filename=IMG_2504.jpg)
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.
Clean
![IMG_20170827_131955.jpg](/proxy/?url=https://content.instructables.com/FWG/H7XQ/J6QQWKFG/FWGH7XQJ6QQWKFG.jpg&filename=IMG_20170827_131955.jpg)
![IMG_20170827_133201.jpg](/proxy/?url=https://content.instructables.com/FGJ/VR29/J6QQWKJE/FGJVR29J6QQWKJE.jpg&filename=IMG_20170827_133201.jpg)
![IMG_20170827_141613.jpg](/proxy/?url=https://content.instructables.com/FRS/BH68/J6QQWKLI/FRSBH68J6QQWKLI.jpg&filename=IMG_20170827_141613.jpg)
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.
Spray
![IMG_2406.jpg](/proxy/?url=https://content.instructables.com/FKC/KIWJ/J6QQWXL7/FKCKIWJJ6QQWXL7.jpg&filename=IMG_2406.jpg)
![IMG_2404.jpg](/proxy/?url=https://content.instructables.com/F5L/VBEL/J6QQWXIY/F5LVBELJ6QQWXIY.jpg&filename=IMG_2404.jpg)
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...
Solder
![IMG_2554.jpg](/proxy/?url=https://content.instructables.com/FL6/XKKX/J6WGFEE7/FL6XKKXJ6WGFEE7.jpg&filename=IMG_2554.jpg)
![IMG_2552.jpg](/proxy/?url=https://content.instructables.com/FQL/Y5MU/J6WGFECD/FQLY5MUJ6WGFECD.jpg&filename=IMG_2552.jpg)
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.
Wiring
![IMG_2507.jpg](/proxy/?url=https://content.instructables.com/FX2/IGQN/J6WGEDLN/FX2IGQNJ6WGEDLN.jpg&filename=IMG_2507.jpg)
![IMG_2515.jpg](/proxy/?url=https://content.instructables.com/FC6/IZI0/J6WGEESP/FC6IZI0J6WGEESP.jpg&filename=IMG_2515.jpg)
![IMG_2510.jpg](/proxy/?url=https://content.instructables.com/FPB/02UG/J6WGEE8W/FPB02UGJ6WGEE8W.jpg&filename=IMG_2510.jpg)
![IMG_2509.jpg](/proxy/?url=https://content.instructables.com/F8T/PKHM/J6WGEE5Q/F8TPKHMJ6WGEE5Q.jpg&filename=IMG_2509.jpg)
* 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.
Code
![Screen Shot 2017-08-29 at 12.13.28 AM.png](/proxy/?url=https://content.instructables.com/F5Z/NLRL/J6WGFPEA/F5ZNLRLJ6WGFPEA.png&filename=Screen Shot 2017-08-29 at 12.13.28 AM.png)
![Screen Shot 2017-08-29 at 12.13.30 AM.png](/proxy/?url=https://content.instructables.com/FUM/DNIK/J6WGFPGF/FUMDNIKJ6WGFPGF.png&filename=Screen Shot 2017-08-29 at 12.13.30 AM.png)
//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; } }
Enjoy!
![IMG_2506.jpg](/proxy/?url=https://content.instructables.com/F8F/FDPR/J6WGEDF8/F8FFDPRJ6WGEDF8.jpg&filename=IMG_2506.jpg)
![IMG_2502.jpg](/proxy/?url=https://content.instructables.com/FT9/8OPR/J6WGECS4/FT98OPRJ6WGECS4.jpg&filename=IMG_2502.jpg)
Enjoy your pretty little sound reactive lamp!