Led Brightness Without Potentiometer With Arduino

by Rachna Aggarwal in Circuits > Arduino

4121 Views, 1 Favorites, 0 Comments

Led Brightness Without Potentiometer With Arduino

Controlling LED brightness

We can glow LED with different brightness in loop without using potentometer also by connecting LED to PWM pins namely, pin 3,5,6,9,10,11 which supply voltage between 0 to 5V .

Resistance between 220 ohms to 1K ohms can be used in resistance with LED.

Component Required

Circuit Schematic

controlling led brightness.PNG
led terminal.jpg

Pin 9 --> led anode

GND--> led cathode

Arduino Code

we use analogWrite function instead of digitalwrite with PWM pins and duty cycle of PWM is between 0 to 255.

analogWrite(pin number, PWM dutycycle);

Code

void setup()

{

pinMode(9, OUTPUT);

}

void loop()

{

analogWrite(9,10);

delay(1000);

analogWrite(9,220);

delay(500);

analogWrite(9,10);

delay(1000);

analogWrite(9,220);

delay(500);

analogWrite(9,0);

delay(500);}

Downloads