This lab introduced us to the Servo, a small motor with an output shaft that can be easily used to create and control motion with a microcontroller. Most servos allow for up to 180 degrees of movement, and can be used in applications involving levers, periodic or reciprocating motions. Servos are commonly used in projects including radio-control airplanes, radio-control cars and robotics, among others.
The goal of the lab was to control the position of the servo using analog sensor values. To set up the breadboard, I connected power and ground on the breadboard to 5V power and ground on the Arduino. I connected an FSR sensor to Analog pin 0 on the Arduino, connected the yellow wire of the servomotor to digital pin 2, the red wire to power, and the black wire to ground.
Part I: Pulsing the servo with a digital pin to set the position of the servo. The first part of the lab involved figuring out the pulse length and position (the easier route would be the Servo library, which we'll see in Part II). I controlled the Servo using an FSR sensor. To ensure that the servo moved through its full range of motion with the FSR, I first determined the range of values of the FSR and used the map(); function to adjust the servo code to fit.
Part II: Controlling the servo using the Servo library. Part I was the hard part - because in Part II, we used the Arduino Servo library to take care of all the calculations.