Stap 30:
Software:
p.MsoNormal, li. MsoNormal, div. MsoNormal {marge: 0.0 in; font-size: 12.0pt; font-family: Times New Roman;} div. Afdeling1 {pagina: Deel1;}
#include < Servo.h >
Servo snoep;
Servo roteren;
Servo klink;
Servo voorjaar;
int brand = 2;
int rechts = 4;
int links = 6;
int val = 0;
int val1 = 0;
int val2 = 0;
int val3 = 0;
VOID Setup
{pinMode(fire,INPUT);
pinMode(right,INPUT);
pinMode(left,INPUT);
Candy.attach(13);
Rotate.attach(12);
Latch.attach(8);
Spring.attach(7);
Rotate.write(45);
delay(500);
Rotate.write(30);
Latch.write(60);
Spring.write(200);
Candy.write(25);
Candy.write(140);
delay(500);
Candy.write(25);
}
void loop
{
Val=digitalRead(Left);
val1=digitalRead(right);
val2=digitalRead(Fire);
Als (val hoog of val1 == == hoog of val2 == HIGH)
{
Als (val == HIGH)
{val3=(val3+5);}
Als (val3 > = 145)
{
val3=(val3-5);
}
Als (val3 < 65)
{
val3 = 65;
}
Rotate.write(val3);
delay(50);
}
anders
Val=digitalRead(Left);
val1=digitalRead(right);
val2=digitalRead(Fire);
if(val1==High)
{val3=(val3-5);
if(val3<65)
{val3=(val3+5);
}
Rotate.write(val3);
delay(50);
}
anders
if(val2==High)
{spring.write(50);
delay(1000);
Latch.write(200);
delay(1000);
Spring.write(200);
delay(500);
Latch.write(60);
delay(1000);
Rotate.write(50);
delay(500);
Rotate.write(30);
Candy.write(140);
delay(500);
Candy.write(25);
val3 = 0;
}}