How to adjust brightness of an LED with Arduino

 Potentiometer With Arduino


Components required:-
1.Arduino Uno:-
2.LEDs:-

3.Portentiometer:-


Potentiometer:-potentiometer is a three-terminal resistor that uses an adjustable voltage divider circuit to create variable resistance.

Potentiometer pinout:-

  1. GND PIN- connected to GND pin of Arduino.

  2. OUTPUT it is an output pin : Connect it to A0 pin of  Arduino.

  3. VCC PIN-  connected to VCC pin of Arduino.


POTENTIOMETER INTERFACING WITH ARDUINO

  • First we have to connect GND pin of Arduino to 1st terminal of potentiometer. 
  • Then we have to connect 2nd pin of potentiometer to A0 pin of Arduino. 
  • Then connect VCC pin of Arduino to 3rd pin of potentiometer. 
  • Then take an LED and connect it's anode terminal to 11th pin of Arduino and cathode pin to GND. 


 Arduino Code

_____________________________________________

int value, tempvalue;

void setup() 

{

 pinMode(11,OUTPUT);

 pinMode(A0,INPUT);

}

void loop()

{

  tempvalue=analogRead(A0);

  value=map(tempvalue,0,1023,0,255);

  analogWrite(11,value);

}

______________________________________
To Understand this project in more detail, then click here or on this image to watch my tutorial

Comments