Friday, July 6, 2012

YAALL = Yet Another Arduino LED Lamp







Projects which makes Arduino "blink" RGB LED's are thousands in the Web. 
So the idea is not fresh at all. It was born when I wanted to write an application for Android platform - for fun and to find out if this is difficult. 

The main assumption of the project that I set: 
-  Remotely controlled (via Bluetooth) lamp where I can change the color of the light (RGB LEDs) 
- "Emergency" control of the lamp by 4 buttons (R-red G-green B-blue, M-mode)

Software: 
The program was created in Eclipse IDE using Java. This is my first Android project so in fact I could not avoid mistakes. I hope there are not too many thought. 
Since it was supposed to be a program just for me I wrote it for the Android version 4.0.3. 
It also has hard-coded address of my bluetooth module, so if someone want to use it has to make changes in source code.

App for my phone in the first version had only three sliders for each color separately. 
Then it were extended on "color picker", 10 favorite colors and the choice of time after which the lamp is off. In addition, I put two buttons to turn lamp on and off and activate the Rainbow mode. 
The values of each color are saved at each change, so when you restart the application everything is as if it would never closed. 
The exception here is the timer, which value I do not save.

This is the application (main screen and "color picker" color selection)






Hardware:
I had few Arduino's in my drawer so choice was kind of obvious. Easy and friendly approach to programming this platform, spokes for itself. For a start and prototype I've chosen to use prefboards - quick and easy solution. When everything was working fine I did better looking PCB's.

I started with one RGB LED. In the final version, I used 31 LEDs. They are connected in parallel. As the load current is quite big it could be difficult for Arduino to survive such, so each color separately, is driven by transistor (BD139).

I bought a bluetooth module which unfortunately works in 3.3V logic. I was forced to use voltage regulator and the MAX3232. Because there were not enough problems signal from BT module appears to be reversed. So I had to run it through inverter. (I used 7400 NAND gate just because I got few of these in my drawer).

Skeleton for mounting LEDs has been made from an empty softdrink bottles. I cut 3 rings in which I made holes for the LEDs. All soldered together so that it forms a rigid structure.

I bought Jonisk lamp from Ikea. It and is "almost" perfect. Almost, because the design (PCB and LEDs) is a bit too high. The light propagates not uniformly and you can see the darker ring on surface where lighting is slightly worse. Maybe I'll add later one more LED ring, to illuminate the darker area.

Adhesive tape visible on the pictures is just to block Arduino and BT module LEDs light.



































Firmware
I started Arduino code with Bluetooth support. When this was up and running I added additional features. As you can see code is very simple and there is nothing revealing. One thing which might be worrying is interrupts. The problem was Rainbow mode from which loop it was not easy to leave. I used interrupts, because I could not come up with anything more clever than that.  So, each RS transmission or pressing "mode" button sets "rainbow" flag to zero.


List of components: 
Arduino Nano - $ 16 or ATMega8 ($ 3)
BTM5 - Bluetooth module - $ 9 
31 RGB LEDs - $ 15 (per 50 LEDs) 
63 resistors to the LEDs (150 - 220R) - choose to desired LEDs current - $ 3 
NAND gate 7400 working as inverter - $ 0.5 
MAX3232 - TTL converter - 232 (running at 3.3V) - $ 0.5 
3.3V regulator - $ 0.5 
3x BD139 - $ 3 
8x 100nF - $ 1 
4x switches - $ 1 
4x 10k resistors 
2x jumper (to disconnect RX and TX line so Arduino can be programmed in the system) 
5V/2A power adapter - $ 5 
Jonisk Ikea lamp - $ 60


Something extra:
Combined Eagle schematic and PCB layout, Arduino code and Eclipse project

2 comments:

  1. Could you and I discuss payment for you to help me with an android app for my product? It's very similar, a 5 channel lighting controller.

    ReplyDelete
  2. Sorry to refuse your kind offer Daniel, but I'm simply out of free time :( That is one. Second thing is, that I'm no expert at all in android developing, so I guess you should find someone more experienced than I am.

    ReplyDelete