
95Chapter 5: The Joy of Joysticks
One of the first things you may notice about this new code example is two
new variables in the section of code about our void setup—our position
variables. They are given an initial value of 90, right in the middle of the
servo’s range of motion—a great place to start the program. Next, inside the
void setup, all we need to do is start up the Serial Monitor, which will allow
us to see the values of our position variables as they change.
Once inside the void loop, first, we need to grab the value of our two joystick
variables by using the analogRead() command on the pins connected
to our joystick. With the value ...