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 (or K) should you use in your project?
Let’s find out if the Potentiometer Values have an impact when read from an Arduino.
SCHEMATIC
PARTS USED
1.
2.
3.
4.
5.
CODE
/*
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);
}
|
No comments:
Post a Comment