loading
 I just got my Arduino starter kit hours ago and i began experimenting with it. This instructable is a good beginner tutorial that will teach you how to:

a. light up an LED
b. light up a RGB LED and use it's three colors
c. get information about what's happening in your arduino through the serial monitor

Of course, lighting up an LED is easy. There's the blink tutorial on how to blink an LED, but I modified it a little bit and jumped to lighting up your RBG LED and get the status of the Arduino through the serial monitor. Well, the arduino won't really tell you anything, but we'll tell it what to tell to us about what we told it to do. Basically, tell us what is the current color of the RBG LED.

This should help you:

a. be able to create status messages on your arduino to be view on the serial monitor so that you know what's happening
b. help you understand why sometimes we need to know what's happening

In this instructable, all you need is available in your Arduino Starter kit from Sparkfun.com. But here's a list:

1. RBG LED
2. 4 wires, preferably 1 black, 1 red, 1 blue, and 1 green
3. a 10kOhm resistor (optional)
4. an Arduino board, the one I used is the Arduino Duemilanove board with ATMEGA328
5. breadboard, or similar

Step 1: Wiring

 Ok let's setup our circuit. It's just a simple circuit so I don't think it will be that hard. I've included really macro/close-up pictures so that you can properly wire them. Oh, and I've used Red wire for the red leg which connects to pin 6, green wire for the green leg which connects to pin 3, blue wire for the blue leg which connects to pin 5, and a black wire which connects to the GND leg and pin of the LED and board, respectively.

I've added a 10kOhm resistor so that I can dim the LED a little bit because without that, the LED shines really bright. I mean, REALLY bright. Although, if you choose not to put a resistor, that's fine. It will still work.

Step 2: Code and Serial Monitor

 Now, upload this code into your arduino, then open the serial monitor to see the magic!

The code is attached, but you can copy paste it from this page www.zeighy.net/site-files/content/public/RBGSERIAL.html


Step 3: Final Remarks

 After uploading the code to your Arduino, it should then be starting to work. Now, you can open the Serial Monitor and see the status. Also, every time you open the serial monitor, it resets the board.

Where do you go from here:

- you can now use other sensors and you can display status using the serial monitor. Check the reference on the Arduino website on how to display values form sensors
- build your own circuit and get status messages from the arduino so that you know what's happening and to know of something is going wrong.
- you might probably want to try out other methods you can use information you get from the serial connection.


Here's a sample run of mine:

Nicely done mate! <br><br>I'll have to go grab all the bits and bobs to put it together, i'll post in the next week or so (or when i can find time) and let you know how i go!<br><br>The thought is using this value to alter a colour scheme on a flash based (only idea at the moment) frontend, and alter the value from the frontend to reflect on the LED's... I'm kinda hobbling together pieces of tutorials from left right and centre, so i'll keep ya posted mate!<br><br>Thanks again for your help, and prompt reply!
nice, update me when you put it up! I'm very interested in setting up a flash front end for arduino, it's just that I failed to do so... haha, can't figure out what I did wrong, or if I was actually doing it right... lol<br><br>wish you all the best! good luck!
Stumbled across this earlier, might help a bit mate!<br><br>http://tv.adobe.com/watch/adc-presents/physical-computing-with-arduino-rgb-led/<br><br>Have a browse through the list of episodes, there's also a bit about wireless control. I haven't tried them yet but the clip seems pretty well thought through and concise, may be handy!
I was wondering if you could report back... Do you know of any way I may be able to retrieve RGB (or hex) values rather then just the solid light? <br><br>I am using a analog control to adjust the RGB values and would like to find a way to reflect that value in an application?<br><br>At a guess it might have something to do with trying to reflect the PW modulations, turning it from a percentage value back to a range from 255?<br><br>I haven't had much of a dabble with all this yet, just browsing about and doing some learning, so if I'm off track please correct me! Any thoughts would be appreciated.<br>
ok got it, yup, you can create a percent situation, I wrote a sketch for this, hope it helps...<br>--- code start ---<br>int RPin = 11;<br>int GPin = 10;<br>int BPin = 9;<br>int activePin;<br>int PWMvalue;<br>double PWMpercent;<br><br>void setup() { <br><br>} <br><br>void loop() { <br>activePin = RPin;<br>PWMpercent = 0.50;<br>getPWM();<br>analogWrite(activePin, PWMvalue);<br><br>activePin = GPin;<br>PWMpercent = 0.50;<br>getPWM();<br>analogWrite(activePin, PWMvalue);<br>}<br><br>void getPWM(){<br> PWMvalue = PWMpercent * 255; // PWMpercent in decimal value e.g. .25 for 25 percent or 1.00 for 100 percent<br>}<br>--- code end --<br><br>make sure you add resistors to avoid burning your LED...<br>my sample basically lights up the red and green at 50% of 255
I haven't really tried... hahaha, lemme check it out for a moment and I'll get back at you in a few minutes...

About This Instructable

4,821views

13favorites

License:

More by zaghy2zy:Getting status through serial monitor 
Add instructable to: