Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
Thread Tools Display Modes
Old 7th June 2008, 04:18 PM   (permalink)
Default Help with RGB LEDs

Hello, I am still fairly new to this so please bare with me.

For my first project I want to have 5 RGB LEDs to fade slowly from color to color. I plan on using a ATMega168 for the PWM. Right, I need to know if my connections shown in my schematic will work. I know that a microcontroller by itself can run a single led from its pins. Since I need to run 5, I used the ULN2003 IC. I found this info here.
Here's my schematic:


Thanks for your help!
PwnToaster is offline   Reply With Quote
Old 7th June 2008, 07:58 PM   (permalink)
Default

(how will you make PWN without capacitors ? and with only 1 bit for each color ?)
your schematic will only make them change into diferent colors but it will not fade, to fade you need PWM to slowlly increase and decrease the voltage on each color.

The i.c. in your design is an power darlington driver, i guess... it is meant to drive dc motors and step motor coils... but it will work for your design, you only need to change the the pins used to control the colors to pins that have PWM outputs, or just make 3 simple 8Bit / 4Bit D/A conv. that with your i.c. will work very nice

have fun
__________________
Best Regards,
Tiago Silva.

Last edited by TiagoSilva; 7th June 2008 at 08:04 PM.
TiagoSilva is offline   Reply With Quote
Old 7th June 2008, 09:57 PM   (permalink)
Default

Quote:
Originally Posted by TiagoSilva View Post
(how will you make PWN without capacitors ? and with only 1 bit for each color ?)
I believe the ATMega168 can generate PWM without capacitors. I'm having trouble finding which pins are for PWM. I need three, obliviously. Thanks for all of your help!
PwnToaster is offline   Reply With Quote
Old 7th June 2008, 09:59 PM   (permalink)
Default

Quote:
Hello, I am still fairly new to this so please bare with me.
Bare with you?! What kind of forum do you think this is, anyway? I think you meant, "bear with me," but in any case, I'm open-minded!

Last edited by Hank Fletcher; 7th June 2008 at 10:01 PM.
Hank Fletcher is offline   Reply With Quote
Old 7th June 2008, 10:09 PM   (permalink)
Default

Quote:
Originally Posted by Hank Fletcher View Post
Bare with you?! What kind of forum do you think this is, anyway? I think you meant, "bear with me," but in any case, I'm open-minded!
Please excuse my horrible spelling.
PwnToaster is offline   Reply With Quote
Old 7th June 2008, 10:17 PM   (permalink)
Default

Quote:
Originally Posted by PwnToaster View Post
I believe the ATMega168 can generate PWM without capacitors. I'm having trouble finding which pins are for PWM. I need three, obliviously. Thanks for all of your help!
The ATMega168 has 6 PWM output pins.

On a 28-pin DIP they are:
PD6 - OC0A - Pin 12
PD5 - OC0B - Pin 11
PB1 - OC1A - Pin 15
PB2 - OC1B - Pin 16
PB3 - OC2A - Pin 17
PD3 - OC2B - Pin 5
__________________
=========================
Futz's Microcontrollers & Robotics
=========================

Last edited by futz; 7th June 2008 at 10:27 PM.
futz is offline   Reply With Quote
Old 7th June 2008, 10:55 PM   (permalink)
Default

Thanks, that helps a lot! Here's an updated picture of my schematic. If I put that button on pretty much any pin from PC0 - PC5, I will be able to detect when it's pushed right? Please excuse my noobiness.
PwnToaster is offline   Reply With Quote
Old 7th June 2008, 11:01 PM   (permalink)
Default

Quote:
Originally Posted by PwnToaster View Post
Thanks, that helps a lot! Here's an updated picture of my schematic. If I put that button on pretty much any pin from PC0 - PC5, I will be able to detect when it's pushed right? Please excuse my noobiness.
Yes. Don't forget a 10K pullup or pulldown resistor on the switch to hold it high or low until it's pressed. If you don't put one, the pin will float when the button isn't pressed, causing randomness. The thing will act like you pressed the button just from you getting your finger near it or bumping the table. Stuff like that.

If you pull it high, then when you press the button the switch should connect to ground.

If you pull it low, then when you press the button the switch should connect to 5V.

Your pullup/pulldown holds the MCU pin at the switch-off voltage level. When you press the button, the switch connects directly to 5V or ground and overpowers the pullup/pulldown.

Have a look at how the pulldown resistors are connected on the schematic on this page.
__________________
=========================
Futz's Microcontrollers & Robotics
=========================

Last edited by futz; 7th June 2008 at 11:10 PM.
futz is offline   Reply With Quote
Old 7th June 2008, 11:19 PM   (permalink)
Default

Quote:
Originally Posted by futz View Post
Yes. Don't forget a 10K pullup or pulldown resistor on the switch to hold it high or low until it's pressed. If you don't put one, the pin will float when the button isn't pressed, causing randomness. The thing will act like you pressed the button just from you getting your finger near it or bumping the table. Stuff like that.

If you pull it high, then when you press the button the switch should connect to ground.

If you pull it low, then when you press the button the switch should connect to 5V.

Your pullup/pulldown holds the MCU pin at the switch-off voltage level. When you press the button, the switch connects directly to 5V or ground and overpowers the pullup/pulldown.

Have a look at how the pulldown resistors are connected on the schematic on this page.
Thanks again for your help. I believe the ATMega168 has internal pull down resistors, so an external resistor is not needed, but thanks for reminding me to enable them!
PwnToaster is offline   Reply With Quote
Old 7th June 2008, 11:40 PM   (permalink)
Default

Quote:
Originally Posted by PwnToaster View Post
Thanks again for your help. I believe the ATMega168 has internal pull down resistors, so an external resistor is not needed, but thanks for reminding me to enable them!
That's probably true. I'm too lazy to look at the datasheet right now. PICs have internal pullups on some ports too.
__________________
=========================
Futz's Microcontrollers & Robotics
=========================
futz is offline   Reply With Quote
Old 8th June 2008, 02:40 AM   (permalink)
Default

I got another question (I'm full of 'em ). What;s the difference between a common cathode and a common anode. I know that a common cathode shares ground and a common anode shares VCC, but whats the advantage of each? I was planning on using common cathode LEDs, but after referring to this page, i saw he used common anodes LEDs. Are they necessary?
PwnToaster is offline   Reply With Quote
Old 8th June 2008, 03:54 AM   (permalink)
Default

Quote:
Originally Posted by PwnToaster View Post
I got another question (I'm full of 'em ). What;s the difference between a common cathode and a common anode. I know that a common cathode shares ground and a common anode shares VCC, but whats the advantage of each? I was planning on using common cathode LEDs, but after referring to this page, i saw he used common anodes LEDs. Are they necessary?
As far as I know there's no advantage or disadvantage. Use whatever suits your circuit, or whatever you have. It's like NPN or PNP transistors. Both work just as good as the other. You pick the one you need to suit what you're doing.

Your message inspired me to dig out the RGB LED I bought last order and tinker with it. I'm putting up an article on my site now. It'll be ready in 10 or 15 minutes. Nothing terribly earth shaking. Just a simple little newb article.
__________________
=========================
Futz's Microcontrollers & Robotics
=========================
futz is offline   Reply With Quote
Old 8th June 2008, 10:38 AM   (permalink)
Default

I prefer common anode devices simply because there's a much larger selection of parallel and serial/spi "sinking" drivers (ULN2803, MIC5821/5841, TPIC6C595, etc.) available to work with compared to "sourcing" drivers like the parallel MIC2981/2982.

Mike
Mike, K8LH is offline   Reply With Quote
Old 8th June 2008, 12:42 PM   (permalink)
Default

PwnToaster, I just looked at your circuit and there is a problem with the way you want to drive the 5 rgb leds.
In the circuit you have shown GND connected to the common Anodes where it should be a positive voltage.
Also, you are driving them in parallel with only 3 resistors in total.
This would not work properly as each led has slightly different turn-on voltage and so some will glow brighter than others.

It needs a resistor for each led (15 in total) to ensure each one gets the same current.
Alternatively you could multiplex them to reduce the resistors to 3 but requires using 5 more outputs on the microcontroller.

It is not essential to use the hardware pwm , it can be done in software for this application.

Last edited by picasm; 8th June 2008 at 12:45 PM.
picasm is offline   Reply With Quote
Old 8th June 2008, 01:04 PM   (permalink)
Default

I recently made up a RGB project with a PIC micro, although different controllers, perhaps the way I went about it might lend you some ideas?

Video of the project


Source code and explanations can be found here Spency's digital-diy 18F PIC micro Tutorial - Red Green Blue (RGB) LED's

Quote:
Originally Posted by picasm View Post
Also, you are driving them in parallel with only 3 resistors in total.
This would not work properly as each led has slightly different turn-on voltage and so some will glow brighter than others.
Its generally a very small difference in brightness, if noticeable at all with good LED's
__________________
Spency.

PIC Micro's - Your mind is the limit

PIC's and interfacing with other devices - a PIC Basic Guide @ digital-diy.net
gramo is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Latest
LEDs RayH General Electronics Chat 33 12th June 2008 08:10 PM
180 leds! justDIY Electronic Projects Design/Ideas/Reviews 4 8th February 2007 05:46 PM
LEDs zachtheterrible Electronic Projects Design/Ideas/Reviews 25 5th October 2004 03:41 PM
RGB LEDs with PWM?? seahkw Micro Controllers 2 27th August 2004 01:30 AM
LEDs-Super Bright White LEDs $1.35USD ea ssullivan777 Datasheet/Parts Requests 0 27th February 2003 02:02 AM



All times are GMT. The time now is 10:21 AM.


Electronic Circuits  |  Electronics Wiki
Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.