Stap 2: upload arduino code
#include < Servo.h >int incomingByte = 0;
Servo myservo;
Servo myservo1;
Servo myservo2;
Servo myservo3;
Servo myservo4;
Servo myservo5;
Servo myservo6;
Servo myservo7;
dubbele pos = 90;
dubbele pos1 = 90;
dubbele pos2 = 90;
dubbele pos3 = 90;
dubbele pos4 = 90;
dubbele pos5 = 90;
dubbele pos6 = 90;
dubbele pos7 = 90;
int aut = 0;
int aut1 = 0;
int aut2 = 0;
int aut3 = 0;
VOID Setup {}
pinMode (13, OUTPUT);
Serial.begin(9600);
myservo.attach(12);
myservo1.attach(9);
myservo2.attach(8);
myservo3.attach(7);
myservo4.attach(6);
myservo5.attach(5);
myservo6.attach(4);
myservo7.attach(3);
myservo.write(POS);
myservo1.write(Pos1);
myservo2.write(pos2);
myservo3.write(pos3);
myservo4.write(pos4);
myservo5.write(pos5);
myservo6.write(pos6);
myservo7.write(pos7);
}
void loop {}
incomingByte = Serial.read();
Als (incomingByte == 66 & & pos > 10) {}
myservo.write (pos-= 0.2);
}
Als (incomingByte == 65 & & pos < 180) {}
myservo.write (pos += 0.2);
}
Als (incomingByte == 68 & & pos1 < 180) {}
myservo1.write (pos1 += 0.2);
}
Als (incomingByte == 67 & & pos1 > 10) {}
myservo1.write (pos1-= 0.2);
}
Als (incomingByte == 97) {}
digitalWrite(13,HIGH);}
Als (incomingByte == 98) {}
digitalWrite(13,LOW);}
Als (incomingByte == 82) {}
aut = 1;}
while(AUT == 1) {}
incomingByte = Serial.read();
voor (pos1 = 10 pos1 < 180; pos1 += 0.2)
{
incomingByte = Serial.read();
myservo1.write(Pos1);
Als (incomingByte == 83) {}
aut = 0;
}
delay(15);
}
voor (pos1 = 180; pos1 > = 10; pos1-= 0.2)
{
incomingByte = Serial.read();
myservo1.write(Pos1);
Als (incomingByte == 83) {}
aut = 0;
}
delay(15);
}
}
Als (incomingByte == 70 & & pos2 > 10) {}
myservo2.write (pos2-= 0.2);
}
Als (incomingByte == 69 & & pos2 < 180) {}
myservo2.write (pos2 += 0.2);
}
Als (incomingByte == 72 & & pos3 < 180) {}
myservo3.write (pos3 += 0.2);
}
Als (incomingByte == 71 & & pos3 > 10) {}
myservo3.write (pos3-= 0.2);
}
Als (incomingByte == 84) {}
aut1 = 1;}
while(aut1 == 1) {}
incomingByte = Serial.read();
voor (pos3 = 10; pos3 < 180; pos3 += 0.2)
{
incomingByte = Serial.read();
myservo3.write(pos3);
Als (incomingByte == 85) {}
aut1 = 0;
}
delay(15);
}
voor (pos3 = 180; pos3 > = 10; pos3-= 0.2)
{
incomingByte = Serial.read();
myservo3.write(pos3);
Als (incomingByte == 85) {}
aut1 = 0;
}
delay(15);
}
}
Als (incomingByte == 74 & & pos4 > 10) {}
myservo4.write (pos4-= 0.2);
}
Als (incomingByte == 73 & & pos4 < 180) {}
myservo4.write (pos4 += 0.2);
}
Als (incomingByte == 76 & & pos5 < 180) {}
myservo5.write (pos5 += 0.2);
}
Als (incomingByte == 75 & & pos5 > 10) {}
myservo5.write (pos5-= 0.2);
}
Als (incomingByte == 86) {}
aut2 = 1;}
while(aut2 == 1) {}
incomingByte = Serial.read();
voor (pos5 = 10 pos5 < 180; pos5 += 0.2)
{
incomingByte = Serial.read();
myservo5.write(pos5);
Als (incomingByte == 87) {}
aut2 = 0;
}
delay(15);
}
voor (pos5 = 180; pos5 > = 10; pos5-= 0.2)
{
incomingByte = Serial.read();
myservo5.write(pos5);
Als (incomingByte == 87) {}
aut2 = 0;
}
delay(15);
}
}
Als (incomingByte == 78 & & pos6 > 10) {}
myservo6.write (pos6-= 0.2);
}
Als (incomingByte == 77 & & pos6 < 180) {}
myservo6.write (pos6 += 0.2);
}
Als (incomingByte == 80 & & pos7 < 180) {}
myservo7.write (pos7 += 0.2);
}
Als (incomingByte == 79 & & pos7 > 10) {}
myservo7.write (pos7-= 0.2);
}
Als (incomingByte == 88) {}
aut3 = 1;}
while(aut3 == 1) {}
incomingByte = Serial.read();
voor (pos7 = 10 pos7 < 180; pos7 += 0.2)
{
incomingByte = Serial.read();
myservo7.write(pos7);
Als (incomingByte == 89) {}
aut3 = 0;
}
delay(15);
}
voor (pos7 = 180; pos7 > = 10; pos7-= 0.2)
{
incomingByte = Serial.read();
myservo7.write(pos7);
Als (incomingByte == 89) {}
aut3 = 0;
}
delay(15);
}
}
Als (incomingByte == 99) {}
aut3 = 1;}
while(aut3 == 1) {}
incomingByte = Serial.read();
voor (pos7 = 10 pos7 < 180; pos7 += 0.2)
{
incomingByte = Serial.read();
myservo1.write(pos7);
myservo3.write(pos7);
myservo5.write(pos7);
myservo7.write(pos7);
Als (incomingByte == 100) {}
aut3 = 0;
}
delay(15);
}
voor (pos7 = 180; pos7 > = 10; pos7-= 0.2)
{
incomingByte = Serial.read();
myservo1.write(pos7);
myservo3.write(pos7);
myservo5.write(pos7);
myservo7.write(pos7);
Als (incomingByte == 100) {}
aut3 = 0;
}
delay(15);
}
}
}