OVERVIEW
In some Arduino projects we will end up using Potentiometers.
The potentiometer (or pot, as it is more commonly known) converts rotary or linear motion into a change of resistance that can be read by an Arduino analog pin.
But which value (ohms) should you use in your project?
Let’s find out if the Potentiometer Values have an impact when read from an Arduino.
PARTS USED
Arduino UNO
10K Potentiometer
These are Amazon affiliate links...
They don't cost you anything and it helps me keep the lights on
if you buy something on Amazon. Thank you!
CONNECTIONS
We are using 4 Potentiometer values: 10K, 50K, 100K and 500K.
The outer pins of each Pot is connected to 5V and Ground from the UNO through a breadboard.
Each Pot center (or Signal) pin, is connected to an Analog pin (A0-A3).
THE CODE
The sketch used to test is using the serial monitor to display the resulting values of each potentiometer values.
Since the Arduino is doing an Analog to Digital conversion, the results will be between 0-1023.
As always please have a look at the tutorial video for more information.
/*
Analog input of different Potentiometers
Testing 10K - 50K - 100K and 500K
*/
// These constants won't change. They're used to give names
// to the pins used:
#define analogInPin0 A0 // Analog input pin that the potentiometer is attached to
#define analogInPin1 A1 // Analog input pin that the potentiometer is attached to
#define analogInPin2 A2 // Analog input pin that the potentiometer is attached to
#define analogInPin3 A3 // Analog input pin that the potentiometer is attached to
void setup() {
// initialize serial communications at 9600 bps
// (Make sure your Serial Monitor window is set to same)
Serial.begin(9600);
}
void loop() {
// display values on the serial monitor:
Serial.print("Pot-10K = ");
Serial.print(analogRead(analogInPin0));
Serial.print(" Pot-50K = ");
Serial.print(analogRead(analogInPin1));
Serial.print(" Pot-100K = ");
Serial.print(analogRead(analogInPin2));
Serial.print(" Pot-500K = ");
Serial.println(analogRead(analogInPin3));
// wait 10 milliseconds before the next loop
delay(100);
}
TUTORIAL VIDEO
DOWNLOAD
Copy the above Sketch code in your Arduino IDE software to program your Arduino.