element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
    About the element14 Community
  • 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
      •  Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      •  Vietnam
      • 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
  • Settings
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
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Arduino to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Verified Answer
  • Replies 24 replies
  • Answers 2 answers
  • Subscribers 419 subscribers
  • Views 3540 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)

e14 Contributor
e14 Contributor over 12 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?

Fullscreen 5415.contentimage_76492.html Download
<html><head><title>Jive SBS</title></head>
<body><font face="arial,helvetica,sans-serif">
<b>Error</b><br><font size="-1">
An general error occurred while processing your request.
</font></font></body></html>

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

  • Sign in to reply
  • Cancel

Top Replies

  • mcb1
    mcb1 over 12 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…
  • e14 Contributor
    0 e14 Contributor over 12 years ago in reply to mcb1

    Checked out that example, basically the same as System.currentTimeMillis(); I use in some single threaded Java programs that render anything on screen; i.e games, to update something such as a sprite movement at certain intervals without calling Thread.sleep(time); so that the whole program doesn't come to a standstill.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • D_Hersey
    0 D_Hersey over 12 years ago

    Rather than futz with your input resistors, consider using (lowish Vgs-th) mosfets.  Then you would have a VCCS rather than a CCCS and wouldn't need the input resistors.  Shut-off (49K, say, between the control terminal and the reference terminal, or do you say 'base' and 'emitter?') resistors would allow you to switch between logic high and tri-state rather than high-and-low, not that it matters much.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • D_Hersey
    0 D_Hersey over 12 years ago

    Oh, I think you are going to want some PU resistors (pull--ups) at the inputs where your switches go.  These inputs are potential (voltage) sensitive and (redundancy alert) therefore high-Z.  Higher conductance of the PU increases power use, with the benefit of slightly less noise, which is a probabilistic thing here.  Remember to at least think about de-bouncing them in software or hardware.  I don't know anything about the input structure associated with this processor.  Maybe you can code a pull-up in firmware.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • mcb1
    0 mcb1 over 12 years ago in reply to D_Hersey

    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 either High or Low.

    The ATmega uP do have inbuilt current limiting (to stop the magic smoke) but those limits also have an overall limitation for the port, that reduces it.

    The need for series resistors on ANY output is something every aspiring engineer should be aware of, and design for to ensure it works as expected.

     

    I've seen FETs die with Gate to Source or Gate to Drain shorts and without any series resistor the uP would release its magic smoke and be dead.

    The use of a MPSA14 and 10k series resistor will work just fine.

     

    Mark

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • mcb1
    0 mcb1 over 12 years ago in reply to e14 Contributor

    I did think the java experience will show through ....image

     

    Its very under utilised and doesn't appear in many examples, which is a shame as it catches out quite a few players. (young and old).

    Just rmember to always subtract and you'll avoid the 49.xx day millis() rollover problems (which never shows during testing)

     

    if you use the EEPROM to store your last settings (for power down), uploading a program doesn't overwrite the EEPROM, which has also caught a few people out.

     

    Mark

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • e14 Contributor
    0 e14 Contributor over 12 years ago in reply to mcb1

    Wouldn't using;
    pinMode(#, INPUT_PULLUP);
    do the same as;

    pinMode(#, INPUT);

    digitalWrite(#, HIGH);

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • D_Hersey
    0 D_Hersey over 12 years ago

    CMOS outputs can typically tolerate indefinite shorts to either supply.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • D_Hersey
    0 D_Hersey over 12 years ago

    I think the fact that the PWM outs are being used is going to preclude this trick.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • shabaz
    0 shabaz over 12 years ago in reply to mcb1

    Agree, with MOSFETs comes great responsibility! Yet many circuits overlook any protection : (. And of course hard nowadays to find in non-SMT TO92-type packages.

     

    By the way Kawandaio in general for lighting applications, the ATmega64 or similar is often better, because it has higher-granularity h/w PWM. 8-bit per channel is acceptable, but for dimming scenarios you can always see the transitions : ) 10-bit is better! Probably way too excessive for this use-case though.

     

    Kawandaio is getting a lot of answers, should be an amazing controller : )

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • D_Hersey
    0 D_Hersey over 12 years ago

    Look, i just don't wanna lead our Joe down the road of becoming that unshaven guy waiting for RS to open in a grimy mac sos he can buy bipolars, one day.  Nobody is doing it this way, nowadays.  One trick, depending on the install, might be to light LEDs in series pairs, doubling the drop, so as to make that nasty ballast resistor smaller.  Another way would be to find an switching current controller chip to run the LEDs, depending on their size.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
<>
element14 Community

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 © 2026 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.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube