Trending

PWM LED Dimmer

Dimming LEDs and other lights using PWM signal from Arduino.



Introduction- 

Pulse width modulation(PWM) is a method of reducing the average power delivered to the load by the electrical signal, by effectively chopping it up in parts. It works by switching on and off the supply at a very fast rate. The longer the switch is on as compared to the off time, the greater the power transferred. Existing application of PWM include, but are not limited to - 

1. Fan speed control
2. LED Dimmers
3. Electric motor speed control

Duty cycle- 

The term duty cycle describes the proportion of 'on' time to the regular interval or 'period' of time.
Duty cycle is calculated by the equation - 
DC = Time On / Time period


Dimming LEDs using PWM-

For the demonstration, I have used an Arduino to generate a variable PWM signal to control the brightness of my LED. 

Connection- 

1. +ve of LED to 5v, -ve of LED to the collector of the transistor.
2. Pin 6 from Arduino to Base of the transistor through 1k ohm resistor.
3. GND to the emitter of the transistor.

Circuit Schematic - 



Arduino Code- 

void setup() {
pinMode(6,OUTPUT);
Serial.begin(9600);
}

void loop() {
  while(Serial.available()>0)
  { int data = Serial.parseInt();
    data = constrain(data,0,255);
    if(Serial.read() == '\n'){
    analogWrite(6,data);
  }
  }
}



The code will allow us to edit the PWM signal output using the serial monitor.
0- 0% duty cycle , 255 - 100% duty cycle.

No comments