Site icon Circuit Ideas for You

Simple Arduino LED Dimmer Circuit using PWM

This post show how to make a Simple Arduino LED Dimmer Circuit using PWM, as PWM changes voltage by changing square wave duty cycle; also it changes duty cycle to make LED more or less bright.

Therefore, more power means more brightness.

Arduino Code:

#define LED_PIN 9
#define BUTTON1_PIN 2
#define BUTTON2_PIN 3

int brightness = 0;

void setup() {
  pinMode(LED_PIN, OUTPUT);
  pinMode(BUTTON1_PIN, INPUT_PULLUP);
  pinMode(BUTTON2_PIN, INPUT_PULLUP);
}

void loop() {
  if (digitalRead(BUTTON1_PIN) == LOW)   
 {
    brightness++;
    if (brightness > 255) {
      brightness = 255;
    }
  }

  if (digitalRead(BUTTON2_PIN) == LOW) {
    brightness--;
    if (brightness < 0) {
      brightness = 0;
    }
  }

  analogWrite(LED_PIN, brightness);
  delay(10);
}

Circuit Working:

Simple Arduino LED Dimmer Circuit Diagram using PWM

Parts List:

ComponentsQuantity
Resistor
220Ω 1/4 watt 1
10k 1/4 watt2
Capacitor
100µF 25V1
Semiconductors
IC 78091
Arduino Uno board1
LED 5mm 20mA any color1
Tactile switches2

LED must connect correct like in circuit diagram, so the push buttons may be unstable, but they will not cause any errors.

Also, using PWM on Arduino is easy and on ATMEGA it is hard because many settings need change; but in Arduino already set these things so we just use right function for PWM and also Arduino makes square wave signal on LED pin.

Furthermore, resistors and capacitor change square wave to DC voltage and duty cycle control average DC voltage which controls LED brightness.

So press button1 the duty cycle goes up and LED goes more bright and then press button2 the duty cycle goes down and LED goes less bright.

How to Build:

To build a Simple Arduino LED Dimmer Circuit using PWM follow the below mentioned steps:

Conclusion:

To conclude, this article for Simple Arduino LED Dimmer Circuit using PWM show how to use PWM with Arduino to control LED brightness in simple and easy way.

Also, by learning PWM and code we can make many light control projects.

Exit mobile version