Arduino PWM Led Control using arduino

Looking for a simple circuit to control the light intensity of Light Emitting Diodes (LEDs) or similar lighting sources? Here is an Arduino based circuit with three independent pulse width modulated (PWM) channels to fulfil your requirements! Just follow the schematic diagram to complete the construction, and use any standard 9VDC Arduino power source to energize the system. Here, for demonstration, three different color LEDs (Red, Green and Blue) are used. You can control the brightness of these LEDs using variable resistors VR1, VR2 and VR3 respectively.

Arduino PWM Led Control

Parts Needed

  • Arduino UNO board – 1
  • 5mm LEDs Red, Green, Blue – each 1
  • 100K Variable resistor – 3
  • 1K ΒΌ w Resistor – 3

Arduino Sketch

  2. //T.K.Hareendran
  3. //
  4. // Analog inputs connected to the variable resistors
  5. const int knobPin1 = 1; //Red LED control
  6. const int knobPin2 = 2; //Green LED control
  7. const int knobPin3 = 3; //Blue LED control
  8. // PWM outputs connected to LED driver circuits
  9. const int drivePin1 = 9;//Red LED drive
  10. const int drivePin2 = 10;//Green LED drive
  11. const int drivePin3 = 11;//Blue LED drive
  12. // initial value for the variable resistors
  13. int knobValue1 = 0;
  14. int knobValue2 = 0;
  15. int knobValue3 = 0;
  16. void setup() {
  17. // set the drive pins as output:
  18. pinMode(drivePin1, OUTPUT);
  19. pinMode(drivePin2, OUTPUT);
  20. pinMode(drivePin3, OUTPUT);
  21. }
  22. void loop() {
  23. // read the variable resistors, convert it to 0 – 255
  24. knobValue1 = analogRead(knobPin1) / 4;
  25. knobValue2 = analogRead(knobPin2) / 4;
  26. knobValue3 = analogRead(knobPin3) / 4;
  27. // use the data to control the drive:
  28. analogWrite(9, knobValue1);
  29. analogWrite(10, knobValue2);
  30. analogWrite(11, knobValue3);
  31. }

Arduino PWM Led ControlEnhancement Ideas

Here, the three LEDs are directly connected to Arduino pins with independent current limiting resistors (R1, R2 and R3) which is enough for a basic model. But if you wish to control Hi-Power LEDs (or similar loads) additional driver circuitry is necessary. For this purpose try the following modification with your working prototype. This is a where a Power Mosfet comes in. With the help of the Power Mosfet, we can use the low voltage output from the Arduino ports to control high voltage/current loads -the popular β€œ12V LED strips”- for instance. Remember to power the output load(s) from a worthy external dc power supply. Part number of the Mosfet is not very critical. Always try to use a type which can safely handle the load current (for example IRF510 or IRF520 MOSFET).


For more detail: Arduino PWM Led Control

About The Author

Scroll to Top