Before I continue. I do not go into details of how to cut the wood, or piece everything together. I freestyled the entire build process, whatever came to mind is what I reproduced. The point of this instructable is to be able to create the circuit, program the arduino, and create something of your own imagination.
Also this instructable is meant for people who are familiar with the ever so popular Arduino !!!
If you want to learn more about what the Arduino is all about please visit : Arduino Home Page
Alright now a little explanation what this exactly is. This is simply an arduino controlling an RGB LED to control lighting. There are 3 different modes. These modes can be selected by pressing a button. The Modes and values of the RGB are being displayed on a LCD screen.
Modes :
1) Hue Cycle : This cycles through the hue spectrum. You scroll the wheel (potentiometer) to control the speed at which the color changes from one to another.
2) Hue Selection : Scroll the wheel (potentiometer) to select the color you chose. IT remains at this color
3) Random Hue : The arduino randomly selects a target RGB color. It fades to that target RGB color. Then the process starts over again. You can select the speed at which the color fades from one to another
The following video is the creation of the Arduino controlled RGB LED Lamp from start to end.
Step 1: Materials
2) Potentiometer : Im using 120ohm but any will do in this particular application.
3) Push Button : Do not use a ON/OFF button. It must be a push button.
4) RGB LED : Make sure it is common cathode RGB LED's. Meaning 1 pin is GROUND and the other 3 pins R,G,B pins are POSITIVE.
5) HD44780-compatible LCD : From my best experience, all 16x2 LCD's I worked with are work with the 4bit library.
6) 5 x Resistors:
- 22ohm = LCD Contrast... *NOTE : Use a POT to determine best contrast for LCD.
- 2.2Kohm = PushButton
- 3 more resistors. You need to determine the values depending on your RGB LED. Details below.
Step 2: Circut Connections
- make sure LCD (RW / PIN5) is hooked to ground.
Theres a mistake in the diagram I made below, it shows LCD PIN 6 is attached to GROUND.... thats wrong, LCD PIN5 is supposed to be attached to ground
- When testing LCD use POT to figure out proper resistence for LCD CONTRAST. You may think LCD isn't working when in actuality the contrast is just to low and you cannot see anything.
- NOT ALL LCD's are made the same. Refer to your LCD specs (google model # of LCD) for pinouts. (DB0-DB7, RegisterSelect , ReadWrite, Enabled, etc)
- RGB PINs needs a proper resistors for each color. The resistor is determined by the amount of voltage each color requires.
Eaxmple:
R = 2.8 - 3.2 volts = 82ohm (recommended)
G = 3.2 - 3.5 volt = 68ohm (recommended)
B = 3.2 - 3.5 volt = 68ohm (recommended)
use following URL to determine resistance for each color. LED series/parallel array wizard
Component Info
Potentiometer (POT) = 120ohm
LCD Contrast resistor = 22 ohm
push button resistor = 2.2 Kohm
LCD Connections
Arduino (GND) = LCD (PIN 1) = Ground
Arduino (5V) = LCD (PIN 2) = Power Supply
Arduino (PIN 2) = LCD (PIN 6) = Enable Signal
Arduino (PIN 7) = LCD (PIN 11) = DB4
Arduino (PIN 8) = LCD (PIN 12) = DB5
Arduino (PIN 9) = LCD (PIN 13) = DB6
Arduino (PIN 10) = LCD (PIN 14) = DB7
Arduino (PIN 11) = LCD (PIN 4) = Register Select
Arduino (PIN 12) = LCD (PIN 5) = Read / Write
RGB LED Connections
Arduino (PIN 3) = LED R = 2.8 - 3.2 volts = 82ohm (recommended)
Arduino (PIN 5) = LED G = 3.2 - 3.5 volts = 68ohm (recommended)
Arduino (PIN 6) = LED B = 3.2 - 3.5 volts = 68ohm (recommended)
Arduino (GND) = LED GND
Button & Pot Connections
Arduino (ANALOG PIN 2) = POT (wiper : usually in the middle, depends on pot)
Arduino (PIN 4) = PushButton (make sure to use 2.2Kohm or higher resistor)
Step 3: Arduino Source Code + Files
Almost all the code was written by myself although I must add credit to the following code which I used.
Arduino Hue Function
select different Modes with push button
The hue function was extremly convienient, why reinvent the wheel.
As for the push button, you wouldn't believe how tricky this can be. This code was extremely helpful to use the pushbutton as I intended. (pressing pushbutton allows you to select different modes)
Step 4: Final words
This project was created as a gift for a very good friend, and now I wish to offer this gift to the rest of the INSTRUCTABLES enthusiasts. This entire process was extremely an amazing experience and Im more than happy to share it with the world.
OH AND PLEASE DON'T FORGET TO VOTE !!!




































Visit Our Store »
Go Pro Today »




<code>\arduino-1.0.1\libraries\LCD4Bit\LCD4Bit.cpp:51:57: error: WConstants.h: No such file or directory
\arduino-1.0.1\libraries\LCD4Bit\LCD4Bit.cpp: In member function 'void LCD4Bit::pulseEnablePin()':
\arduino-1.0.1\libraries\LCD4Bit\LCD4Bit.cpp:86: error: 'LOW' was not declared in this scope
\arduino-1.0.1\libraries\LCD4Bit\LCD4Bit.cpp:86: error: 'digitalWrite' was not declared in this scope
\arduino-1.0.1\libraries\LCD4Bit\LCD4Bit.cpp:87: error: 'delayMicroseconds' was not declared in this scope
\arduino-1.0.1\libraries\LCD4Bit\LCD4Bit.cpp:89: error: 'HIGH' was not declared in this scope
\arduino-1.0.1\libraries\LCD4Bit\LCD4Bit.cpp:92: error: 'delay' was not declared in this scope
\arduino-1.0.1\libraries\LCD4Bit\LCD4Bit.cpp: In member function 'void LCD4Bit::pushNibble(int)':
\arduino-1.0.1\libraries\LCD4Bit\LCD4Bit.cpp:101: error: 'digitalWrite' was not declared in this scope
\arduino-1.0.1\libraries\LCD4Bit\LCD4Bit.cpp: In member function 'void LCD4Bit::commandWriteNibble(int)':
\arduino-1.0.1\libraries\LCD4Bit\LCD4Bit.cpp:149: error: 'LOW' was not declared in this scope
\arduino-1.0.1\libraries\LCD4Bit\LCD4Bit.cpp:149: error: 'digitalWrite' was not declared in this scope
\arduino-1.0.1\libraries\LCD4Bit\LCD4Bit.cpp: In member function 'void LCD4Bit::commandWrite(int)':
\arduino-1.0.1\libraries\LCD4Bit\LCD4Bit.cpp:156: error: 'LOW' was not declared in this scope
\arduino-1.0.1\libraries\LCD4Bit\LCD4Bit.cpp:156: error: 'digitalWrite' was not declared in this scope
\arduino-1.0.1\libraries\LCD4Bit\LCD4Bit.cpp:159: error: 'delayMicroseconds' was not declared in this scope
\arduino-1.0.1\libraries\LCD4Bit\LCD4Bit.cpp: In member function 'void LCD4Bit::print(int)':
\arduino-1.0.1\libraries\LCD4Bit\LCD4Bit.cpp:166: error: 'HIGH' was not declared in this scope
\arduino-1.0.1\libraries\LCD4Bit\LCD4Bit.cpp:166: error: 'digitalWrite' was not declared in this scope
\arduino-1.0.1\libraries\LCD4Bit\LCD4Bit.cpp:167: error: 'LOW' was not declared in this scope
\arduino-1.0.1\libraries\LCD4Bit\LCD4Bit.cpp: In member function 'void LCD4Bit::clear()':
\arduino-1.0.1\libraries\LCD4Bit\LCD4Bit.cpp:186: error: 'delay' was not declared in this scope
\arduino-1.0.1\libraries\LCD4Bit\LCD4Bit.cpp: In member function 'void LCD4Bit::init()':
\arduino-1.0.1\libraries\LCD4Bit\LCD4Bit.cpp:192: error: 'OUTPUT' was not declared in this scope
\arduino-1.0.1\libraries\LCD4Bit\LCD4Bit.cpp:192: error: 'pinMode' was not declared in this scope
\arduino-1.0.1\libraries\LCD4Bit\LCD4Bit.cpp:200: error: 'delay' was not declared in this scope
\arduino-1.0.1\libraries\LCD4Bit\LCD4Bit.cpp:206: error: 'delayMicroseconds' was not declared in this scope
\arduino-1.0.1\libraries\LCD4Bit\LCD4Bit.cpp: In member function 'void LCD4Bit::leftScroll(int, int)':
\arduino-1.0.1\libraries\LCD4Bit\LCD4Bit.cpp:287: error: 'delay' was not declared in this scope
\arduino-1.0.1\libraries\LCD4Bit\LCD4Bit.cpp: In member function 'void LCD4Bit::rightScroll(int, int)':
\arduino-1.0.1\libraries\LCD4Bit\LCD4Bit.cpp:296: error: 'delay' was not declared in this scope</code>
How can I fix this?
Thanks in advance.
is in this folder : \arduino-1.0.1\libraries\LCD4Bit\
because thats what its looking for when compiling.
normally on pc you have the full path c:\arduino\libraries\lcd4bit\LCD4Bit.cpp
I got the library off the arduino site.
Perhaps (actually im pretty sure) they have a newer library for LCD screen.
Alot has changed with arduino since 2009
Check it out the following link:
http://arduino.cc/playground/Code/LCD
hope this helps...
cheers
I'm going to try adapting the code for the LiquidCrystal library.
I do seem to be getting some color flickering during certain colors. I'm trying to debug the code but may be asking for some advice.
Thanks.
Phil
1) Bad Led, try seeing if this happens with other LEDS. Check wiring and contacts as well.
2) To much processing between loops. For LED's to fade nicely they need to turn on and off really quick. Any processing in between and you will lose fractions of seconds during the fading. Causing the flicker. There is a function that sets RGB values called h2rgb(). If you are doing something like code below, this will definitely cause flickering.
loop(
//lines of code that
- any cpu instensive code
- receiving serial data
- sending serial data
h2rgb(h,r,g,b);
)
Also consider that this code was built on Arduino running at 16mhz (16,000 times per second) if your running a Arduino Nano 8mhz your running the loops at HALF the speed. The code itself may need to be optimized for slower clock cycles.
Hope this helps you out.
Cheers
Cheers.
Phil
Cheers
Joe
Even just doing this simple code:
for (int i=0; i< 25 ; i++) potAvg += analogRead(potPin);
potVal = potAvg / 25 ;
Serial.println (potVal);
To average the value, it still shows potVal to be inconstant, usually it fluctuates + or - 1 value but that is enough to cause a flicker on a static hue.
any ideas?
Thanks.
Phil
1) The pot is wired wrong, goto this link for quick reference:
http://www.arduino.cc/en/Tutorial/Potentiometer
2) The pot is wired correctly, ALTHOUGH theres a short, or a "shared" pin that sux the voltage out of the pot. So if the voltage is fluctuating, then the values of the pot will fluctuate.
try reading voltage of the pot... is the voltage flucating? If so then theres a short or some wiring is done wrong... If your using the LCD, try testing without LCD hooked up. You should be able to control the LED easily with just pot plugged in. If that works, then try to debug if the LCD is causing the issue.
Hope this helps.
Cheers
http://arduino.cc/forum/index.php/topic,115652.0.html
Thanks.
Phil
When you mentioned you tried SEVERAL POTS I was like... hmmmm well can't be the POT since you tried several of them. I think you just have bad batch pots.
if your POT fluctates just by a few integer values (+ or - 5) then using 8bit (0-255 instead of 0-1023) would definitely resolve that issue.
Glad you have it all resolved! Isn't debugging problem FUN!!! :) haha...
cheers
I will be looking at the code this weekend to see if I can reproduce the issue and see if I can debug it.
Thanks.
Phil
Thumbs Up!
Build_it_Bob
The LCD contrast for my display ( UNIQe/Vision GC-1602I1 ) requires the contrast pin to be pulled to ground via resistor. I used a 1Kohm variable and found that 780 ohms gave the best visability.
This paves the way for many ideas ...THANK YOU Silverbyte and contributors !
Awesome project ...I have it running now and it looks great on the customized board I made for it.
Build_it_Bob
Build_it_Bob
Yes you can just use a 1RGB led + Arduino Duemilanove. Any Arduino compatible board will work. Although I have extra code to select the different modes with a pushbutton and select its values with the potentiometers
You can remove alot of uneeded code (for the pushbutton and the LCD) , or you can refer to the following link
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1207331496
which is the main function which controls the RGB values.
If your a beginner and new to programming, this is where i'd start.
If your a good programmer then you can attack my code. You'll notice my code needs some cleaning up (project was done within timeframe so i scrambled through everything) but you can tackle it pretty easily.
cheers