Arduino Music Desk Lamp With Bluetooth!

by Arpan Mondal in Circuits > Arduino

4601 Views, 4 Favorites, 0 Comments

Arduino Music Desk Lamp With Bluetooth!

20181103_182234_0001.png

Hello there! In this Instructable I'm going to build something bright! Let me introduce you to my cool new desk lamp! Its a cheap diy solution to turn your boring desk into a DJ night attraction! Or may be not. But I assure you that the final product is going to be cool! So let's get making!!

Components:

1. Arduino Uno (Nano would be a better option)

2. Bluetooth audio receiver

If you're in India, you can get it from here: https://www.amazon.in/dp/B00K85W0TG/ref=cm_sw_r_c...

US:

https://www.ebay.com/itm/Wireless-Bluetooth-3-5mm-...

3. LEDs (I used a strip)

4. Speakers (I had an audio amplified speaker system)

5. Jumper cables

Tools:

1. Soldering iron

2. Glue gun (optional)

The BlueTOOTH Receiver!

IMG_20181102_211530.jpg
IMG_20181102_211518.jpg
IMG_20181102_211710.jpg

So let's begin with the easy part. I got a cheap Bluetooth audio receiver for 110 Rupees (around $ 1.5)

Just remove the casing of the device and the small circuit board can be easily taken out. Don't worry, we're not going to deal with all the complicated stuff on that.

Make sure to handle it carefully or you'll need to get another one if anything breaks. On one side you'll find the USB power input and on the other side, the female audio output. We need to solder 2 wires to this output on the parts indicated in the image 3. These are basically one of the two output pins to the speaker. Make sure you don't mess with the inside of the output connector or you'll not be able to insert the audio jack of your speakers later.

The DJ LEDs

IMG_20181103_114435.jpg
IMG_20181103_114409.jpg
IMG_20181103_114329.jpg

Get 4 LEDs of any color and solder all their negative pins on a single piece of wire. Solder separate wires to each of the positive pins of the LEDs. SAFETY FIRST! Use a soldering iron stand if available. And safety gloves and goggles are recommended. Use a small fan to direct the fumes away from you.

You don't have to be restricted to four LEDs though. If you're familiar with Arduino, you can easily program it to control more.

You could use an RGB strip for more control but I tried to keep it as simple as possible since using an RGB strip will require a lot of programming.

I've used a normal LED strip and cut four parts out of it with 3 LEDs in series in each part. This will give out more light from the lamp and I don't have to use a current limiting resistor too.

The First Test

IMG_20181103_160051.jpg
IMG_20181103_160052.jpg

This part is going to be easy if you've used four LEDs like me. You can just copy my code, paste it in the Arduino ide and directly upload it. But it will not be an accurate light show. So if you want to make it look professional, here's what you need to do..

First, insert your speakers to the bluetooth receiver.

Now type the following code in the Arduino ide:

void setup()

{

Serial.begin(9600);

}

void loop()

{

Serial.println(analogRead(A0));

}

Now connect your Arduino uno/nano to your computer and upload the sketch.

Connect one of the soldered wires(on the Bluetooth circuit) to the A0 pin of the Arduino and the other wire to the ground pin (GND). Connect your smartphone to the Bluetooth receiver and play something. You should hear the music in your speakers. Adjust the volume to your most comfortable level (for me it's Max volume :-) ). Make sure your Arduino is still plugged in to your PC. Click on tools–> serial monitor and you should see random numbers being displayed. It might be too fast for you to note them down. So, go back, click on tools–> serial plotter and you'll see the graph of your audio being played. Take a few screenshots or photos for later analysis.

If you're curious about the music I played for the test, its 'Sunflower' from Spiderman in the Spider verse

Coding...

This part might be boring for some people. But trust me, the beauty of your end product is dependent on this. I have kept it as simple as possible. First have a look at my code and try to understand what's going on. We will do a code walk through in the end.

I have attached the docx file of my code. You can go through that.

Once your code is ready, you can upload it to the Arduino. Oh yeah, make sure the Arduino isn't connected to anything else other than your PC.

Downloads

The Second Test

IMG_20181102_211550.jpg

Remove your Arduino from the PC and connect a 9-12v Power supply to it (9v recommended). Now connect the positive pins of your LEDs to the outputs of your Arduino (in this case, pin 6, 7, 8, 9). Connect the common negative terminal to the GND pin. Connect the wires from your Bluetooth receiver to the A0 and GND pins of your Arduino and play some music (via Bluetooth).

If the LEDs flash to your music, you've done a great job. Because for me, the first time it didn't. Neither did any sound come out of the speakers. And most importantly, the song was being played directly via my mobile speaker. It couldn't connect to the Bluetooth! Then I found that two of the contacts in the USB power input of the Bluetooth board were broken. That's the problem with cheap stuff. I had to solder them to the board and everything worked flawlessly! Although I used normal blue LEDs for the test instead of my strip.

Cool, let's make the lamp!

The Lamp

IMG_20181103_115426.jpg
IMG_20181103_185605.jpg

I found two small PVC pipes, but I needed a single long one. So, I glued them together with a smaller pipe inside it for reinforcement. Later I stuck the four LED strips equidistant from each other on the pipe. You can see how 'neat' I have kept everything in the image :-p

Let's call this the 'core' of our lamp. I made the outer body by simply rolling an A4 size paper into a cylinder. As simple as that! Actually I thought of making a permanent version of this if everything works fine.

The Final Test!

Before packing everything inside a box, I wanted to have a final check. I hooked up the core to the Arduino, powered up everything, played a cool music and...

Nothing happened. Not even a single LED tried to glow! I double checked everything and later realized that the LEDs were 12v each!

An Arduino's output pin can supply a Max voltage of~3.3v. This is enough for normal LEDs but these Led strips require 9-12v. I could have connected them through a separate power supply using a Transistor for each LED, but this would ruin the simplicity of the project.

So, I replaced them with 4 single red LEDs and again started the test. The LEDs finally blinked to my music but for some weird reason, the fourth LED didn't glow. I modified the script and reduced the cut off voltage for the fourth LED to glow but no improvements were seen. I then made the cutoff voltage of the fourth LED same as the third one and repeated the test. Nope, no glow seen. I later modified the script to control 5 LEDs and repeated the experiment. Now the fourth and fifth LED refused to glow. Weird. I made a couple of other tests and tweaks but nothing changed. So I finally used only three LEDs.

Rock 'n' Roll!!

IMG_20181103_185953.jpg
IMG_20181103_182034.jpg
IMG_20181103_160401_HDR.jpg
IMG_20181103_160339_HDR.jpg

Finally I packed all the electronics inside a box and fixed the core of the lamp vertically on it. I then placed my paper cylinder around it and let the music reach out to everyone's ears. Yeah! It looked cool! Not as much as I expected, but still pretty good. I wanted a yellow lamp though. Red looked good to. And I got a cheap Bluetooth speaker from my boring USB ones.

Code Walk Through

Before you hit the back button seeing the title of this step, please vote this instructable for the contests it is in. Thank you.

You can find the doc version of the code attached in this step.

As I said (many times), the code is simple. We have declared an integer 'sound' to store the sound level from the input. There's a small mistake in the setup function. Analog pin 'A0' is defined as the input pin (instead of 'soundpin'). Pins 6, 7, 8, 9 are defined as the output pins.

In the loop function, we begin by a condition asking all LEDs to turn on if the sound input is greater than 35. Similarly we have three more conditions targeting particular LEDs for a particular range of inputs. And in the end, if no input is received from A0, all LEDs are set off.

Hope you understand. I tried my best, beacause I'm a beginner to Arduino! And yes, this is my first Instructable!

Please let me know if I need to make any changes in my Instructable. See you until the next one!

Downloads