Stap 8: Het programma!
Hier is de code die ik schreef voor de helm. Wellicht sommige kalibratie om te werken met je gezicht. Omdat we alle unieke, yada yada yada.
// Written by Simone Giertz #include <Servo.h> Servo servo[3]; // base, upper arm, lower arm static const int servoPin[3] = {7,8,6}; void setup() { Serial.begin(9600); for(int i=0; i<3; i++){ servo[i].attach(servoPin[i]); } // Fold the robot arm at the top of the helmet servo[0].write(90); // base servo[1].write(30); // upper arm servo[2].write(150); // lower arm } void loop() { // Wait five seconds before we start the toothbrushing delay(5000); // Put the arm in brushing position servo[1].write(180); servo[0].write(90); servo[2].write(70); delay(1000); // brush back and forth for(int i = 0; i<10; i++){ servo[2].write(60); delay(200); servo[2].write(120); delay(200); } // Fold the robot arm back up servo[0].write(90); servo[1].write(30); servo[2].write(150); }