ROBOT MAGIC
CHAPTER Seven: Cuber Goober
Copy + Paste this code to your Arduino Sketch:

/* Sweep
by BARRAGAN <http://barraganstudio.com>
This example code is in the public domain.
modified 8 Nov 2013
by Scott Fitzgerald
http://www.arduino.cc/en/Tutorial/Sweep
*/
#include <Servo.h>
Servo Mouth; // create servo object to control a servo
Servo Rubiks;
int pos = 50; // variable to store the servo position
void setup() {
Mouth.attach(9); // attaches servo on pin 9 to object
Rubiks.attach(11);
Mouth.write(0);
Rubiks.write(180);
delay(500);
}
void loop() {
delay(10000);
//MOUTH CLOSES
for (pos = 0; pos <= 70; pos += 1) { /* goes from 0 to 70
degrees in steps
of 1 degree */
Mouth.write(pos); // go to position 'pos'
delay(25); /* waits 25ms for the
servo to reach the
position */
}
delay(2000);
//MOUTH OPENS
for (pos = 70; pos >= 0; pos -= 1) { /* goes from 70 to 0
degrees in steps
of 1 degree */
Mouth.write(pos); // go to position 'pos'
delay(25); /* waits 25ms for the
servo to reach the
position */
}
delay(2000);
Mouth.write(70); //MOUTH OPENS
delay(1000);
Mouth.write(0); //MOUTH CLOSES
delay(1000);
Mouth.write(70); //MOUTH OPENS
delay(500);
Mouth.write(0); //MOUTH CLOSES
//HERE CUBE ROTATES
delay(100);
Rubiks.write(0);
delay(250);
//MOUTH OPENS
for (pos = 0; pos <= 70; pos += 1) { /* goes from 0 to 70
degrees in steps
of 1 degree */
Mouth.write(pos); // go to position 'pos'
delay(25); /* waits 25ms for the
servo to reach the
position */
}
delay(3000);
Mouth.write(0); //MOUTH CLOSES
delay(100);
Mouth.write(0);
Rubiks.write(180);
delay(50000);
}
