
27Chapter 1: The Foundation of Robotic Arms
STEP 1
For our next circuit, feel free to keep the servo wired up just as it was in our
previous examples. We are, however, going to swap our two push-buttons
for a potentiometer. A standard potentiometer has three pins. In this circuit
(Figure
1-31
), the two outside pins will be connected to the positive and
negative rail of the breadboard, and the middle pin will be connected to
analog pin A0 on the Arduino:
STEP 2
#include <Servo.h>
int pos;
void setup() {
Serial.begin(9600);
}
void loop() {
pos = analogRead(A0);
Serial.println(pos);
delay(100);
}
Once you have written up this next sketch, upload the code. Then, ...