LED Dimmer using Arduino Uno
This is the introduction of PWM (Pulse Width Modulation) concept in Arduino Uno. Here we have used the PWM method to vary the brightness of a 1 Watt LED.
All the header files and registers are predefined by ARDUINO IDE, we simple have to call them and that’s it we will have a PWM output at appropriate pin.
Now for getting a PWM output at a appropriate pin, we need to work on two things,
1. pinMode(ledPin, OUTPUT)
- analogWrite(pin, value)
First we need to choose the PWM output pin from six pins, after that we need to set that pin as output.
Next we need to enable the PWM feature of UNO by calling the function “analogWrite(pin, value)” . In here ‘pin’ represent the pin number where we need PWM output we are putting it as ‘3’. So at PIN3 we are getting PWM output.
Value is the turn ON duty cycle, between 0 (always off) and 255 (always on). We are going to increment and decrement this number by button press.
See the source code to understand the working.