Tuesday, August 14, 2018

LED and Potentiometer Using Arduino

Control the blinking rate of the light-emitting diode(LED) by using a potentiometer. So, what is a potentiometer? 

The potentiometer is an instrument, it has three terminal variable resistors. It manually controls the flow of electric current. Two terminal is connected to the resistive element and the third is connected to the adjustment wiper. which means that the rotation of the of the wiper may determine the output voltage.
Potentiometer
Required.
1 x LED color as you like.
Arduino board
Wire,
Breadboard
Potentiometer
Resistor 330Ω

1. Connect to the breadboard

Connect According to the diagram as I have shown you. In the above figure, the black wire is connected to the GND pin and the red wire is connected to the 5V pin above the GND pin in the Arduino board. Connect LED as shown here. Now place your potentiometer on the breadboard, as shown in the diagram. the potentiometer has 3 terminal. The first terminal (blue & black wire) is connected to the negative terminal, the last terminal (orange & red wire) is connected to the 5v. The green wire is taken from the middle terminal to A0 (analog) in the Arduino board.  



2. Open Arduino IDE software 
 Type the code: 


int sensorPin = 0;

int ledPin = 13;

void setup()

{

  pinMode(ledPin, OUTPUT);

}

void loop()

{

int sensorValue;

  sensorValue = analogRead(sensorPin );

  digitalWrite(ledPin , HIGH);                                   

  delay(sensorValue);                                                  

  digitalWrite(ledPin, LOW);                                 

  delay(sensorValue);                                                  


}


3. Verify and Upload code to Arduino Board
Once the code is Verified and uploaded to your Arduino Board, then you notice rapid blink of LED for one second. Do not worry, it is an indication that your code is successfully uploaded.

DONE
Start to rotate the mover of the potentiometer in order to get the result.

if it is not working let me know down in the comment. 

GOOD LUCK

0 comments: