Instructables
Picture of Arduino RGB LED Lamp + 4bit LCD Display
rgbLamp3.jpg
_lamp.jpg
_3color.jpg
_LCD.jpg
_scroll.jpg
This is my first instructable !!! yay..

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.



 
Remove these adsRemove these ads by Signing Up
1-40 of 111Next »
marios85431 year ago
Can you make the diagram on fritzing?? It's much easier to read. Thanks
ARR82 years ago
 
 
Hi, I recently tried this project, and gotup to where I compile the code. However, when I try to compile, I get a bunch of errors:

<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.
silverbyte (author)  ARR82 years ago
Its not finding the "LCD4Bit.cpp" library. "LCD4Bit.cpp" is in the Zip I believe. Copy it to to proper folder and restart arduino sketch.
ARR8 silverbyte2 years ago
I copied the whole LCD4Bit folder into the libraries folder. Is that what I'm supposed to do?
silverbyte (author)  ARR82 years ago
as long as this file: LCD4Bit.cpp
is in this folder : \arduino-1.0.1\libraries\LCD4Bit\
because thats what its looking for when compiling.

ARR8 silverbyte2 years ago
I verified that it is, but I still get those errors.
silverbyte (author)  ARR82 years ago
hmmmm.... is it a PC or MAC?
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


ARR8 silverbyte2 years ago
It's a PC, but I cut off the beginning of the path (C:\Users...etc.)
I'm going to try adapting the code for the LiquidCrystal library.
philspitler2 years ago
This is a great project, I'm adapting the code for an art project I am currently doing and it's really helping me.

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
silverbyte (author)  philspitler2 years ago
Color flickering can be caused by 2 things in my experience.

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

It looks like the flickering is the pot. I am printing the value of the pot and it's not stable. I'll try another pot or maybe I will do some kind of averaging in code.

Cheers.

Phil
silverbyte (author)  philspitler2 years ago
Glad you debugged the problem. I'd try to change the pot, no need to add extra code for averaging unless you really need it.
Cheers
Joe

I tried changing the pot and I get flickering on every pot I try.

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
silverbyte (author)  philspitler2 years ago
The values of the pot should be stable. Either 2 things could have gone wrong. 

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






Thanks silverbyte, the pot is wired correctly, I posted my issue on the Arduino forum and somebody said it sounded like noise. They suggested shifting from 10 bits to 8 which really helped.

http://arduino.cc/forum/index.php/topic,115652.0.html

Thanks.

Phil
silverbyte (author)  philspitler2 years ago
AHH GOOD CALL!!!

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
Thanks silverbyte, I believe the flickering was happening when I was on a solid color, not a fade. It is running on a Uno and is powering 30 feet of RGB LED strips.

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
Dekel Ziv2 years ago
it's much like my project, only that yours is a bit more complicated
Thumbs Up!
Man I got it, took a couple days, but she is working great, I cant wait to build the finished product now, thanks so much for the great indestructible. For proto newbie to like me, remember to check the LCD4Bit file completely, changing pin values as needed, as well as the sketch, and beware of the few mistakes on the fritz, first time I pressed the button, it reset the arduino and windows started installing drivers for god knows what...so i cancelled that quick and redid the switch according to the arduino site, other than that, I used a slider pot and have a rgb lcd on the way to hopefully parallel to the other led for more effect, and add an on/off switch and reset if needed...I may do the same and give it as a present. Next I will learn to make a bare naked setup like yours to make it a neater device...again thanks a bunch from Big D.
This looks awesome! I just purchased an Uno and am looking forward to trying this. Thanks for sharing!
Build_it_Bob
silverbyte (author)  Build_it_Bob4 years ago
Thanks. Id like to mention that the LCD library has come a long way since I developed this project. You may want to use the new library than the one I provide in this project. cheers
LCD now working along with serial out !!!
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
silverbyte (author)  Build_it_Bob4 years ago
Thats awesome im glad your project turned out great. Cheers and happy holidays
I hope to have a few hours tonight to try this out. I have an Amicus 18 as well as the Arduino Uno and I enjoy lights and lighting control. The Arduino has a lot more info and projects available, and yours has the right mix for control . I will post back with any progress , and once again great work .
Build_it_Bob
handyman294 years ago
Can I use an Arduino Duemilanove? And also, is the LCD display nessesary or can I just hook up the LEDs and potentiometers to the Arduino? Thank you.
silverbyte (author)  handyman294 years ago
No you don't need the LCD. The LCD is just there to show the 3 different modes and its RGB values. It will still work without an LCD screen.

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
raikoug4 years ago
Hi, i use this lcd http://www.sparkfun.com/commerce/product_info.php?products_id=9052 but I really can't see anything write on... maybe is a bit different couse of white on black... i'm a bit new.. (I use an arduino 2009, the leds with pot and bott work fine) can you hlp me please? thanks
raikoug raikoug4 years ago
nono... now work... but I don't have clear writes... it give me strange signs: "?" "/" "o" arrows and a think a jap letter... what is going on? :D thanks
silverbyte (author)  raikoug4 years ago
- if you can't see text on screen it can be because of 2 things a) you need to add a resistor or potentiometer on the contrast pins b) You must tie the LCD's R/W pin to ground ( check LCD datasheet) c) check page 6 on the LCD datasheet, http://www.sparkfun.com/datasheets/LCD/ADM1602K-NSW-FBS-3.3v.pdf - if you get garbage this should be simple. a) change your BAUD rate to a lower rate (to start try 9600) b) reset arduino whenever you change pins on powered unit c) double check all your connectiong. Make sure all your pins are correct. All LCD's are made differently so maybe you pins are mixed up.. Check page 5 in the LCD datasheet http://www.sparkfun.com/datasheets/LCD/ADM1602K-NSW-FBS-3.3v.pdf Im glad your getting along with your project your almost there... when i first did this project i spent 3 days trying to get my LCD to work. Hope this helps cheers Joe
I'm really happy of existence of people like you... thanks for all your work! than... I can see the words... but.. aren't the words i should see.. i see strange simbols.. I saw the datasheet at page 5 of my lcd and I found that all pins are the same (only but of 15 and 16 that I have to hookup, they'r the back ground... but that was really easy). now... the problem i that the db pins (the ones responsable of the word mixing I suppose) are exactly the sames as your... and not only... i tried to see the arduino.cc libraries manual.. i hooked them to see only the lcd.. and when I start it... it gives me this strange letters... I've a video: (made by a nokia) http://www.megaupload.com/?d=MLLFUHML thanks for all!!
raikoug raikoug4 years ago
omg... I saw another wonderfull thing of my lcd (that i suppose to be broken...) I restart the arduino i load the program but nothing... everything work but the lcd.. for I don't know why in the world... I unplud the arduno 11 and 12 from the lcd... than I plug them (casually) to 3-4 ... and it starts writing nonsense characters... and the strangest thing is that If i unplug those 2 pins anfter all this... lcd still write the same things!!! I wish it isn't my poor arduino board...
raikoug raikoug4 years ago
it's not the lcd... I tried with another lcd and the same history.. strnag symbols... :( what the hell :(
silverbyte (author)  raikoug4 years ago
hmmm heres a hunch... I think you "ENABLE" pin is set to 3 and not 2 in the library. Open up the file : LCD4Bit.cpp :::: //-------------------------------------------------------- int _registerSelect = 12; int _readWrite = 11; int _enablePin1 = 2; int _enablePin2 = 3; int _dataBits[] = {7, 8, 9, 10}; int Enable = _enablePin1; //-------------------------------------------------------- In my library I set the Enable pin to pin 2 on the arduino. I think i may have changed this because im using the PWM on pin 3.... I think in your library its pin 3. Try this, see what results you get.
i'll try as soon as possible! if it will works I will love you!! :P
raikoug raikoug4 years ago
nthing.. the pin was right. is there something wrong in the db positions... it's really strange.. :(
silverbyte (author)  raikoug4 years ago
It is strange, but i had the exact same result as you at one point. are you sure these pins are not mixed up Arduino (PIN 11) = LCD Register Select Arduino (PIN 12) = LCD Read / Write I would start a new Arduino sketch, and just plug the LCD and start debugging with that. Also go over to the Arduino webpage and checkout there LCD4Bit library section. Im certain you'll get it soon: Arduino (PIN) 7,8,9,10 = LCD(DB4,DB5,DB6,DB7) Arduino (PIN 2) = LCDenable pin Arduino (PIN 11) = LCD Register Select Arduino (PIN 12) = LCD Read / Write
I've done it!!! finally, with a 3° lcd I made it!! IT WORKS!!! Thanks a lot for all help you gave me! you are a friend ;) See you soon ^^
silverbyte (author)  raikoug4 years ago
HAHAH!!! awesome... I NEW IT TOO!!! once you get it its pretty damn satisfying. I made 2 or 3 other LCD projects and sometimes i hit the same bump on the road, but patience and persistence is key. you should youtube a video of your project when completed, I'd like to see it. cheers, Joe
I sure will!! ;) thanks a lot!
Nothing... I tried but it is always the same, and I tried a lot of combinations!! (i tried the liquid cristal libraries with his connection... but I can't compile couse of and error (I used the examples codes..) so I can't test the connections :( )
1-40 of 111Next »