## Description:

This week Molly and I teamed up to have a crawler for the TUI crawler challenge! We used 2 servomotors and a large battery pack, and some earplugs for grip on the carpet. It was difficult to stabilize the body – we tried markers, triangle shaped highlighters, and ended up using the servo box with clips to raise it.

## Components

• 1x Arduino
• 1x servomotor
• 1x box
• 2x paperclip
• 1x battery pack
• 4x ear plug
• 10x+ rubber bands and hair ties

## Code

``` /* * Code modified from this code: http://www.robotoid.com/appnotes/arduino-operating-two-servos.html */ #include Servo servoLeft; // Define left servo Servo servoRight; // Define right servo int pos7 = 0; int pos8 = 0; void setup() { servoLeft.attach(8); // Set left servo to digital pin 8 servoRight.attach(7); // Set right servo to digital pin 7 servoLeft.write(0); servoRight.write(0); } void loop() { // Loop through motion tests moveR(); // Example: move forward moveL(); // moveR(); // moveL(); // moveR(); // moveL(); } // Motion routines for forward, reverse, turns, and stop void moveR() { //servoLeft.write(0); //servoRight.write(130); for (pos7 = 0; pos7 <= 120; pos7 += 5) { // goes from 0 degrees to 180 degrees // in steps of 1 degree servoRight.write(pos7); // tell servo to go to position in variable 'pos' delay(15); // waits 15ms for the servo to reach the position } for (pos7 = 120; pos7 >= 0; pos7 -= 10) { // goes from 180 degrees to 0 degrees servoRight.write(pos7); // tell servo to go to position in variable 'pos' delay(15); // waits 15ms for the servo to reach the position } } void moveL() { //servoLeft.write(130); //servoRight.write(0); for (pos8 = 0; pos8 <= 120; pos8 += 5) { // goes from 0 degrees to 180 degrees // in steps of 1 degree servoLeft.write(pos8); // tell servo to go to position in variable 'pos' delay(15); // waits 15ms for the servo to reach the position } for (pos8 = 120; pos8 >= 0; pos8 -= 10) { // goes from 180 degrees to 0 degrees servoLeft.write(pos8); // tell servo to go to position in variable 'pos' delay(15); // waits 15ms for the servo to reach the position } } ```