Back

Andy's Assignment 4!

Here is an image of my circuit.

Here is an gif of my circuit working. The servo motor will move between 0 and 180 degrees depending on where I move the joystick.

Using the servo library, I used pin 9 to write to the servo how many degrees of movement I wanted. I put the SW of the joystick to pin 2, but did not use the feature of a push on the joystick in my code. This means it wasn't necessary to plug in, but I thought I might as well. Instead of being powered by pins, both the servo and joystick were powered by 5V given through the arduino and shared through the breadboard to ground.

Here is my code with comments explaining how it works. I use the default values of 0 and 1023 for my values' min and max because the analog channel ranges between these values. This means the neutral position is 511 and 511 for x and y.