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 &lt;<a href="http://barraganstudio.com/" target="_blank" data-saferedirecturl="https://www.google.com/url?hl=en&amp;q=http://barraganstudio.com&amp;source=gmail&amp;ust=1476725158252000&amp;usg=AFQjCNEtAsotC8FoEERQ3L7tZlE7qzEjOA">http://barraganstudio.com</a>&gt; 

 This example code is in the public domain.

 modified 8 Nov 2013

 by Scott Fitzgerald

 <a href="http://arduino.cc/en/Tutorial/Sweep" target="_blank" data-saferedirecturl="https://www.google.com/url?hl=en&amp;q=http://arduino.cc/en/Tutorial/Sweep&amp;source=gmail&amp;ust=1476725158252000&amp;usg=AFQjCNFbhjp8v_fLHwCEwLBWq6db81Ygew">http://arduino.cc/en/<wbr />Tutorial/Sweep</a>

*/ 

#include &lt;Servo.h&gt; 

 

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 &lt;= 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&gt;=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