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.
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