Introduction: Led Brightness Without Potentiometer With Arduino

About: pursuing Bachelors in Electronics and Communication at Chandigarh University

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.

Step 1: Component Required

Step 2: Circuit Schematic

Pin 9 --> led anode

GND--> led cathode

Step 3: 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);}