
114 Make: Robotic Arms
Just as before, most of our code looks the same.
The key differences are the few areas of code in
which we’ve added the variables associated with
our joysticks back in. In the area above our void
setup, we’re created two new variables, xval and
yval. These are the variables we’ll use to store
our joystick data. Next, inside of our void loop,
we assign a value to our two joystick variables
through the analogRead() command by using
our two analog input pins to read the changing
voltages coming from the two axes of the
joysticks. Lastly, we create a series of conditional
statements based on the position of the joysticks