Lesson 5: Potentiometer
A potentiometer is a variable resistor with adjustable resistance. Potentiometers are used in robotics as regulators of various parameters - volume of sound, power, voltage, etc.
In this lesson we will connect potentiometer to Arduino, and look to its signal values through 'Serial monitor'.
Scheme on breadboard:
Upload this code, and open 'Serial Monitor' in Arduino IDE application. Then rotate Potentiometer to see changes:
void setup()
{
//initialize A0 port as INPUT
pinMode(A0, INPUT);
//initialize Serial port to 9600
Serial.begin(9600);
}
void loop()
{
//print the result of Potentiometer in Serial monitor
Serial.println(analogRead(A0));
//wait 2 seconds
delay(2000);
}
Comments
Post a Comment