element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Members
    Members
    • Benefits of Membership
    • Achievement Levels
    • Members Area
    • Personal Blogs
    • Feedback and Support
    • What's New on element14
  • Learn
    Learn
    • Learning Center
    • eBooks
    • STEM Academy
    • Webinars, Training and Events
    • More
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • More
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • More
  • Products
    Products
    • Arduino
    • Dev Tools
    • Manufacturers
    • Raspberry Pi
    • RoadTests & Reviews
    • Avnet Boards Community
    • More
  • Store
    Store
    • Visit Your Store
    • Choose Another Store
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
Arduino
  • Products
  • More
Arduino
Arduino Forum 16 RGB LED's in parallel controlled by atmega328 PWM pins for pc case mod. (Updated)
  • Blog
  • Forum
  • Documents
  • Events
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Arduino requires membership for participation - click to join
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Verified Answer
  • Replies 24 replies
  • Answers 2 answers
  • Subscribers 103 subscribers
  • Views 545 views
  • Users 0 members are here
  • pc
  • case-mod
  • atmega328
  • arduino
  • rgb-led
Related

16 RGB LED's in parallel controlled by atmega328 PWM pins for pc case mod. (Updated)

Former Member
Former Member over 8 years ago

Ok I'll start by saying i'm totally new to electronics, (Java programming is my hobby) I'm also new to this site, (The Ben Heck Show brought me here).

Basically I have a really cool plan for a PC build I just completed, all of the fans have 4 blue LED's. I want to replace those with RGB LED's Allowing me to choose any colour I like to suit my mood.

The controls will be mounted in an empty 5.25" drive bay, And consist of 4 push buttons and an RGB led.

Button 1: Mode (Cycle through pre-set colour cycling modes, and static user defined color)

Button 2: +

Button 3: -

Button 4: Colour Select (R, G, B)

You cycle through the pre-sets with the Mode button pre-set X > pre-set X > user defined

The front panel RGB LED will be off while in pre-set mode, when you reach user-defined mode the led will light fully red indicating that the + and - buttons will affect the Red value of the fan lights

Pressing the Color Select button will cause the front rgb led to change to Blue allowing you to alter the Blue value, a further press changes to green then back to red

 

I'm also hoping in the future to have control over serial from a program running on the pc I intend to write (using one of those SparkFun USB to serial breakout boards connected to an internal USB header) https://www.sparkfun.com/products/718

 

The entire lighting system will get its power from a 4 pin molex connector coming from the PC PSU

 

I mocked up a schematic of the circuit in Fritzing, I'm guessing it will work properly, however I may be totally incorrect and pop something

 

The Micro-controller used will be an ATMEGA328 with the arduino boot loader mounted in a socket on the PCB

its supply voltage will come from the 12V pin of the Molex through a 7805 Voltage regulator

 

Was also wondering could I do-away with the voltage regulator and power the chip directly using the 5V pin of the molex?

The connector labelled C4 will go to the LED's

The RGB LED's will be Common Anode each colour connected in parallel each with its own current limiting resistor , they will be switched using 3 NPN Transistors one for each colour.

From my calculations based on figures I found on-line each LED colour drawing 20ma * 16 = 320ma per colour channel so my transistors need to be able to switch that load

 

My main question, Will this work how I have designed it, or will I destroy something? and is there a better way?

 

Edit:

After doing some research i found using common cathode RGB LED's with PNP transistors wouldn't have worked the way I intended, so i have updated the schematic to reflect this

  • Reply
  • Cancel
  • Cancel

Top Replies

  • mcb1
    mcb1 over 8 years ago in reply to D_Hersey +1

    Don

     

    re ATmega 328 as used in this application.

    Maybe you can code a pull-up in firmware.

    Thats what the PinMode and DigitalWrite does as stated in Post #2

     

    There is no "Tri State' on a digital output, its…

  • johnbeetem
    0 johnbeetem over 8 years ago

    I don't see anything obviously wrong, but this is only my opinion with NO WARRANTY.

     

    I don't see any reason to use +12V and a regulator: I'd go with +5V from the power supply.  Be sure to keep the 10 uF bulk bypass cap and add a 0.1 uF ceramic cap for the processor.

     

    20 mA per LED seems like a lot these days.  I recommend that you try various resistor values starting with 1K to see how bright you really want it.  Also, different color LEDs typically have different voltage drops and different efficiencies, so you may need different resistor values to get the right color mixture.

     

    I recommend prototyping on a solderless breadboard to get it working before making your final resistor selections and soldering it up.

    • Cancel
    • Up 0 Down
    • Reply
    • Verify Answer
    • Cancel
  • mcb1
    0 mcb1 over 8 years ago in reply to johnbeetem

    The only comments I 'd make is that AREF isn't tied to 5v on most other boards.

    It can be set under software so they usually keep it isolated.

     

    You also seem to have no high freq filter caps (0.1uF) showing across the supply lines

    R54-57 aren't required if you set the pullups to on.

    Pinmode(xx, INPUT);

    DigitalWrite(xx, HIGH);

    will set the internal 20k resistors and achieve the same thing.

     

    Depending on the gain (Hfe) of transistors Q4-6 you might want to drop the R51-53 down to 4k7 or 2k7 to ensure you fully saturate the C-E at 100% PMW.

    And don't forget the series resistor on the RGB leds

     

    Mark

    • Cancel
    • Up 0 Down
    • Reply
    • Verify Answer
    • Reject Answer
    • Cancel
  • Former Member
    0 Former Member over 8 years ago

    Made some changes based on feedback, I still need to correctly calculate the values of R1, R2 and R3

    • Cancel
    • Up 0 Down
    • Reply
    • Verify Answer
    • Cancel
  • mcb1
    0 mcb1 over 8 years ago in reply to Former Member

    Looking good.

     

    I'd change the 10uF to 1000uF (or even larger) since the 5v is also supplying your RGB leds which are 320mAx3 (960mA)

    (A rough rule of thumb is 1000uF per Amp)


    For R1-3 you may wish to use a darlington transistor that is capable of 500mA ie MPSA13 or MPSA14 which have a gain of 10-20,000, then you can use a 10k resistor.


    Try to keep your current paths seperate, ie the ground for Q1-3 should go to the supply, the ground for the ATmega 328 should go to the supply and both join at the supply point.

    A bit like keeping heavy traffic from residential streets but joining them at the motorway on-ramp.

     

    Your FTDI ground should go to the ATmega.

    The idea is to keep any switching currents from influencing the processor.

     

    Most of the ccts I've seen also have a 10k to +5v from the RST pin, and use a 0.1uF to DTR

    Without it it can float, and possibly reset when you don't expect, or not always reset.

     

    (Arduino Pro shown below)

     

    Mark

    • Cancel
    • Up 0 Down
    • Reply
    • Verify Answer
    • Reject Answer
    • Cancel
  • Former Member
    0 Former Member over 8 years ago in reply to mcb1

    Thanks very useful points, as i said i'm totally new to electronics so this project is more of a learning experience for me than just to create something that lights up. You said that the FTDI ground should go to the ATmega, i don't fully understand how you mean, wouldn't that mean the ATmega would be disconnected from the supply ground?

    • Cancel
    • Up 0 Down
    • Reply
    • Verify Answer
    • Cancel
  • Former Member
    0 Former Member over 8 years ago

    Here is what i have now,

    I've Tried to keep current paths separate best as possible.

    Changed the filter cap from 10uf to 1000uf.

    The transistors switching the LED's will be MPSA14's (however couldn't find any Darlinton transistors in fritzing) and updated their resistors accordingly.

    Changed the 22pf to a 0.1uf and added a 10k resistor to +5V on the DTR to reset line.

    Also noticed in my last revision that instead of sending +5V out to the LED's i had the pin connected to ground

    • Cancel
    • Up 0 Down
    • Reply
    • Verify Answer
    • Cancel
  • mcb1
    0 mcb1 over 8 years ago in reply to Former Member

    Oops

    I posted and you updated while I was constructing the reply.

     

    Normally a drawing doesn't match the physical layout, however this is a good exercise to get you thinking about avoiding the pitfalls.

    As you become more familiar with electronics these become second nature ... but they still creep up behind you and slap you if you are sloppy.

     

    If you build it very similar to your drawing (ie laying it out in the same manner), you should avoid any potential headaches.

     

     

     

    one minor edit ... I'd make the 10k on the reset connect to the ATmega supply line, rather than the 5v to the leds.

     

    Well done.

     

    Now the code ....

     

     

    Cheers

    mark

    • Cancel
    • Up 0 Down
    • Reply
    • Reject Answer
    • Cancel
  • mcb1
    0 mcb1 over 8 years ago in reply to mcb1

    sorry I made an edit while you were marking it.

    mark

    • Cancel
    • Up 0 Down
    • Reply
    • Verify Answer
    • Cancel
  • Former Member
    0 Former Member over 8 years ago in reply to mcb1

    No worries. And thank you for your help, I really do appreciate it.

    I love learning new things. This project is a way for me to learn something new and make something i want in the process, Its actually a good way of learning, your motivation to carry on comes from seeing your idea turn into an actual thing and the satisfaction you get from seeing your creation working at the end of it makes you want to go further, learn more and create more complex things.

    There is probably hundreds of systems pre-built to do what i'm trying to make here, but by building it myself not only do i learn something, but at the end of it i can step back and say "i made that".

    It was the same when i started learning Java, started with a small simple project, and worked my way up from there, did some dabbling with android apps just to learn something else. Wrote tons of programs most of them to serve a purpose, and aid in doing tasks i do regularly, most where a success, a few failed, but the fun is in trying.

     

    But now down to the code for this, I'm looking forward to this part.

    Also amended my schematic

    • Cancel
    • Up 0 Down
    • Reply
    • Verify Answer
    • Cancel
  • mcb1
    0 mcb1 over 8 years ago in reply to Former Member

    The above attitude to learning will hold you in good stead here .......

     

    But now down to the code for this, I'm looking forward to this part.

    Plenty of comments so that six months later you (and any others) can understand why you did that bit that way....

     

    Have a look at the example "Blinkwithoutdelay" in the IDE to use the inbuilt millis() timer, rather than a delay.

    Don't forget to enable the pullups on the three button inputs, and I use a small delay (25mS) then check again to de-bounce the switches.

     

     

    Cheers

    Mark

    • Cancel
    • Up 0 Down
    • Reply
    • Verify Answer
    • Cancel
>
Element14

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2022 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • Facebook
  • Twitter
  • linkedin
  • YouTube