# # Exercise 1: Servos

You were introduced to the field of engineering robotics and the Arduino programming basics you will see in the workshop. Here you will learn some hardware basics.

The main goal of the exercise is to get acquainted with the Arduino IDE, and confirm that the servos work as expected.

## # Move a robot!

Meet our robot. It has 2 servo motors that control the two side wheels and a small caster wheel. In order to control the motors, we use a library Servo.h. To include the library into our program we use the `#include <Servo.h>`.

After we include the library we can create two `Servo` objects of, which is done on line 3 and 4 in the Arduino sketch. For every servo variable, we give it a name to be able to use it afterwards in our code. Inside the setup function, we will attach the pin number to the library servos. The left one is at pin 9 and the right servo at pin 10. This is done on line 7 and 8.

To control the servo, we can write to it an angle from 0 to 180. At 90 the continuous servo does not move. And as you increase the value towards the 180 or decrease it towards 0, the servo will change the speed in the specific direction clockwise or anticlockwise, depending if the angle is above or under 90.

The following program writes an angle of 170 to the left servo and then waits for 3 seconds. After that it writes 90 to both servos for them to stop. Modify the code to collect all 3 coins.

HINT

The servos are installed opposite to each other. If the servo motors are both moving clockwise (or anticlockwise), then they will be turning in opposite directions relative to each other. Choose the right numbers between 0 and 180 to make the servos rotate so that the robot moves straight.

5. Optional: If you have quickly accomplished this task, try modifying your code by using `nameservo.write` commands in `void loop`. Challenge yourself to write a move straight function and call it in the loop. Then try to write other functions like turnLeft, turnRight, or something more ambitious like zigZag.