Arduino LED PWM Control

Arduino PWM Led Control

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.

Parts Needed

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

Schematic of Arduino PWM LED Controller Circuit

Arduino LED PWM Control

Arduino Sketch

// Analog inputs connected to the variable resistors
const int knobPin1 = 1; //Red LED control 
const int knobPin2 = 2; //Green LED control 
const int knobPin3 = 3; //Blue LED control 
// PWM outputs connected to LED driver circuits
const int drivePin1 = 9;//Red LED drive
const int drivePin2 = 10;//Green LED drive
const int drivePin3 = 11;//Blue LED drive
// initial value for the variable resistors
int knobValue1 = 0;
int knobValue2 = 0;
int knobValue3 = 0;
void setup() {
   // set the drive pins as output:
   pinMode(drivePin1, OUTPUT);
   pinMode(drivePin2, OUTPUT);
   pinMode(drivePin3, OUTPUT);
void loop() {
   // read the variable resistors, convert it to 0 - 255
   knobValue1 = analogRead(knobPin1) / 4;
   knobValue2 = analogRead(knobPin2) / 4;
   knobValue3 = analogRead(knobPin3) / 4;
   // use the data to control the drive:
   analogWrite(9, knobValue1);
   analogWrite(10, knobValue2);
   analogWrite(11, knobValue3);

Enhancement Ideas

enhancement 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).

Pulse-width modulation (PWM)

PWM signals of varying duty cycles  High ON

Pulse width modulation (PWM) is a powerful technique for controlling analog circuits with a microprocessor’s digital outputs. Pulse-width modulation,as it applies to LED control, is a way of delivering energy through a succession of pulses rather than a continuously varying (analog) signal. By increasing or decreasing pulse width, the controller regulates energy flow to the LED. An analog signal has a continuously varying value, with infinite resolution in both time and magnitude. By controlling analog circuits digitally, system costs and power consumption can be drastically reduced. Arduino already include on-chip PWM controllers, making this effectuation easy. In short, PWM is a way of digitally encoding analog signal levels.


myduino LED PWM

Looking for a solution to build this circuit on a general-purpose circuit board? Just follow the schematic diagram shown below to complete your own Arduino circuit board!

About the ATmega 328 chip
It is a good idea to use a socket for the chip. If the chip is pre-programmed, you should be in business. The following steps will outline the process.

  • Procure one Atmega328 chip with pre-burned Arduino Bootloader
  • Replace the original chip in your Arduino board with this one
  • Now upload the sketch to the 328 chip ,as usual, using Arduino IDE
  • Remove the chip and insert it into your circuit board’s IC socket
  • Ready, Set and GO!

atmega328 pin mapping

Note: Pin D9 on the Arduino is not the same pin 9 on the ATmega328 IC. Pin 15 on the IC is actually the pin for Digital Pin 9 (D9) on the Arduino. If you want to see the pinout for the ATmega328 IC, refer the “Pin Mapping” diagram.


Join the conversation!

Error! Please fill all fields.
  • decevreisastiileeching-net

    I have tested this circuit, the diagram in the first picture, but the potentiometers are in fact parallel with each other with as result that they influence each other. Is there a solution for to avoid this?

  • Philip Adrian Morales

    good day, can I ask for an automatic dimmer of LED without using potentiometer. Ill just use a push button and 3 LED(Red, Green, Blue) and an arduino. When I push a button, The 3 LED light sequence is (Red, Green, Blue) and will open slowly. and when I push again the button, the LED will change the Sequence to (Blue, Blue, Blue) and it will also open slowly. and when I push again the button, the LED will change the Sequence to (Green, Blue, Green) and it will also open slowly. can you help me sir? 🙂

  • mondher

    hi nice work but i wont ask you i can do this with rx tx 433 mhz with ( radio fréquence )

  • Jack

    Hello, is there any way to drive more than the 3 LED, I am a newbie in this field and would like to see an application where about 10 led are driven with different flash rates. Thanks you