Stap 3: Servo's verbinden met Arduino
Rechtstreeks verbinden met twee servo's Arduino Uno signaal, 5vcc en gnd pin 9 en 11.
Arduino schets als volgt uitgevoerd:
#include servo.h
Servo servo1, servo3;
int ledPin = 13; Selecteer de pin voor de LED
VOID Setup {}
Serial.begin(9600);
pinMode (ledPin, OUTPUT); de ledPin verklaren als uitgang
servo1.attach(9);
delay(10);
servo1.write(110); vinger in de uitgangspositie
servo3.attach(11);
delay(10);
servo3.write(71); schuifregelaar positie op de uitgangspositie
delay(5000); wacht 5 seconden voordat u begint
}
VOID playKey (int slidePos) {}
servo3.write(slidePos); schuifregelaar servo naar belangrijke positie verplaatsen
delay(300); geven van de schuifregelaar voor tijd om er te komen
servo1.write(85); vinger omlaag en druk op toets
delay(100); tijd om de vinger omlaag
servo1.write(110); vinger terug halen
delay(300); Geef tijd te vinger halen voordat de volgende regelaar gaan
}
void loop {}
digitalWrite(ledPin,HIGH);
/ * playKey (165); //f delay(500); playKey (149); //g playKey (138) //a playKey (127) //b playKey (116); //c playKey (105); //d playKey (94), //e playKey (83); //f playKey (72), //g playKey (61); //a playKey (50); //b playKey (28); //c playKey (15); //d * /
cetk / /
playKey(71); playKey(60); playKey(83); playKey(170); delay(400); playKey(116); delay(2000);
Avengers / /
playKey(72); playKey(94); playKey(83); playKey(50); playKey(15); playKey(28); playKey(72); playKey(94); playKey(83); delay(2000); Amazing grace playKey(160); playKey(116); playKey(94); playKey(94); playKey(105); playKey(116); playKey(138); playKey(149); delay(2000);
Indiana jones
playKey(138); playKey(127); playKey(116); playKey(83); delay(500); playKey(149); playKey(138); playKey(127); delay(500); playKey (116) //c playKey (105) //d playKey (94); //e playKey (50); //c playKey (105); //d playKey (94), //e playKey (83); //f playKey (72); //g playKey (61); //a delay(2000);
Gilligan
playKey (138) //f playKey (105) //g playKey (61); //a playKey (61); //f playKey (61); //g playKey (72); //a playKey (94), //f playKey (116); //g delay(500); playKey (138) //f playKey (105) //g playKey (61), //a playKey (61), //f playKey (61); //g playKey (72); //a delay(500); playKey (138) //f playKey (105) //g playKey (61); //a playKey (61), //f playKey (61); //g playKey (72), //a playKey (28); //a delay(500); //a playKey (83), playKey (72); //a delay(500); playKey (94), //a playKey (116), //a playKey (105); //a delay(2000);
ergens over de regenboog
playKey(127); delay(300); playKey(50); delay(300); playKey (61), //f delay(300); playKey(83); playKey (72), //g playKey (61), //a playKey (50); //b delay(200); playKey(125);delay(300); playKey(72);delay(300); playKey(83); cli(); / * playKey (149); //g playKey (138) //a playKey (127) //b playKey (116); //c playKey (105); //d playKey (94), //e playKey (83); //f playKey (72), //g playKey (61); //a playKey (50); //b playKey (28); //c playKey (15); //d * /
}