Meet Bruce

This weekend, Andrea and I teamed up to create a little robot named Bruce.  We were able to get him to move forward (albeit in a somewhat circular pattern) by altering the starting and ending servo motor angles. We also had to compensate for the second servo motor being in a reverse position from the first. We modified the code by adding the second servo, such that for when one’s angle was 70 for example, the second would be 180-70.

Photo of Bruce

Watch Bruce go!


components

  • 2 servo motors
  • a box lid
  • 10 bamboo sticks
  • 3 furniture pads
  • 1 lobster mascot (named Bruce)
  • 3 plastic spoons
  • 1 ball of putty
  • A lot of electrical tape
  • 1 9v battery + connecter
  • 1 arduino
  • 1 breadboard
  • several connecting wires

code

/* Sweep

 by BARRAGAN <http://barraganstudio.com> 

 This example code is in the public domain.




 modified 8 Nov 2013

 by Scott Fitzgerald

 http://arduino.cc/en/Tutorial/Sweep

*/ 




#include <Servo.h> 

 

Servo myservo;

Servo myservo1;// create servo object to control a servo 

                // twelve servo objects can be created on most boards

 

int pos = 0;    // variable to store the servo position 

int potPin = A0;

 

void setup() 

{ 

  myservo.attach(9);  // attaches the servo on pin 9 to the servo object 

  myservo1.attach(10);

} 

 

void loop() 

{ 

  for(pos = 70; pos <= 180; pos += 1) // goes from 70 degrees to 180 degrees 

  {                                  // in steps of 1 degree 

    myservo.write(pos); 

    myservo1.write(230 - pos);

    Serial.print(-pos);    // tell servo to go to position in variable 'pos' 

    delay(7);    // waits 15ms for the servo to reach the position 

  } 

  for(pos = 180; pos>=70; pos-=1)     // goes from 180 degrees to 70 degrees 

  {                                

    myservo.write(pos); 

    myservo1.write(230 - pos);    // tell servo to go to position in variable 'pos' 

    delay(7);                       // waits 15ms for the servo to reach the position 

  } 

}

Leave a Reply