Paso 30:
Software:
p.MsoNormal, li. MsoNormal, div. MsoNormal {margen: 0.0 en; font-size: 12.0pt; font-family: Times New Roman;} div. Sección 1 {página: sección 1;}
#include < Servo.h >
Caramelo del servo;
Servo rotación;
Cierre del servo;
Resorte del servo;
fuego de int = 2;
int derecha = 4;
int izquierda = 6;
int val = 0;
int val1 = 0;
int val2 = 0;
val3 int = 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);
Si (val == alta o val1 == alta o val2 == HIGH)
{
Si (val == HIGH)
{val3=(val3+5);}
Si (val3 > = 145)
{
val3=(val3-5);
}
Si (val3 < 65)
{
val3 = 65;
}
Rotate.Write(val3);
Delay(50);
}
otra cosa
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);
}
otra cosa
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;
}}