Potentiometer as simple sensor with Arduino

 A potentiometer is a basic and useful component which can be used a user adjustable simple sensor. A potentiometer is a variable resistor which can be used to vary resistance in a circuit by rotating it's knob. By rotating its knob, it allows us to control voltage and current in electronics circuits. We can use it to control things like robotic hand, intensity of a particular light, control speed of DC motors, control of Stepper motor and control of servo motors, frequency control of devices that depends on frequency. The Arduino analog pin can be used to sample the voltage from the potentiometer. By change the resistance using POT, the voltage also changes which can be detected by the Arduino analog pins. Thus a potentiometer can be used as a simple sensor for testing purpose and other useful tasks. 

 

Here, we will use a 10KOhm potentiometer as a simple sensor to control the frequency of LED blink. The following circuit diagram shows how to connect the potentiometer, the LED with Arduino Uno.

circuit diagram of Potentiometer as simple sensor with Arduino
 The middle terminal of the POT is connected to analog A0 pin of the Arduino Uno. The two other ends of the POT are connected to +5V and ground. The LED two terminals are connected to +5V(longer leg) and the ground as shown above.

 The following arduino program will read the potentiometer adjusted voltage and this read value is used to change the frequency of LED blink.



int sensorPin = A0; // Set alias name for analog pin A0
void setup(){
// Set the built in LED pin as OUTPUT
pinMode(LED, OUTPUT);
}
void loop(){
// Read the value of the sensor
int potval = analogRead(sensorPin);
// Blink the LED with a delay of one forth of the sensor value
digitalWrite(LED, HIGH);
delay(potval/4);
digitalWrite(LED, LOW);
delay(potval/4);
}

 

Following are some example usage of potentiometer.

Arduino Stepper Motor Speed Control with Potentiometer

- DC motor Speed control with Potentiometer and PWM using Arduino

- How to control Servo Motor Control using Arduino Nano 

 



Post a Comment

Previous Post Next Post