Paso 2:
Software:
#include < Servo.h >
int ledPin = 13;
int minutos = 0;
int hora = 7; tiempo en 7 de inicio
Chi de int = 0;
int valm1 = 0;
Servo myservo;
lastTick largo sin signo estático = 0; configurar una variable local para celebrar la última vez que nos desplazamos hacia adelantados cinco minutos
movimiento hacia adelante de cinco minutos cada 300000 milisegundos
void setup() {//set entradas y salidas
myservo.Attach(5);
pinMode (ledPin, salida);
}
void loop() {}
Si (millis() - lastTick > = 300000) {}
lastTick = millis();
minuto ++;
}
mover hacia adelante una hora cada 12 intervalos de cinco minutos
Si (minutos > = 12) {}
hora ++;
minuto = 0; poner minutos a cero
}
Si (hora > = 13) {}
hora = 1;
minuto = 0; poner minutos a cero
}
Valm=analogRead(0);
if(Valm>400) {}
Delay (10);
Valm=analogRead(0);
if(Valm>300) {}
digitalWrite (ledPin, HIGH);
dunk de la aves
if(hour == 1) {}
myservo.Write(10);
Delay(500);
myservo.Write(90);
Delay(500);
}
if(hour ==2) {}
myservo.Write(10);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(10);
Delay(500);
myservo.Write(90);
Delay(500);
}
if(hour == 3) {}
myservo.Write(10);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(10);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(10);
Delay(500);
myservo.Write(90);
Delay(500);
}
if(hour == 4) {}
myservo.Write(10);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(10);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(10);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(10);
Delay(500);
myservo.Write(90);
Delay(500);
}
if(hour == 5) {}
myservo.Write(10);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(10);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(10);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(10);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(10);
Delay(500);
myservo.Write(90);
Delay(500);
}
if(hour == 6) {}
myservo.Write(10);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(10);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(10);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(10);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(10);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(10);
Delay(500);
myservo.Write(90);
Delay(500);
}
if(hour == 7) {}
myservo.Write(10);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(10);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(10);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(10);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(10);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(10);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(10);
Delay(500);
myservo.Write(90);
Delay(500);
}
if(hour == 8) {}
myservo.Write(10);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(10);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(10);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(10);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(10);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(10);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(10);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(10);
Delay(500);
myservo.Write(90);
Delay(500);
}
if(hour == 9) {}
myservo.Write(10);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(10);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(10);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(10);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(10);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(10);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(10);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(10);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(10);
Delay(500);
myservo.Write(90);
Delay(500);
}
if(hour == 10) {}
myservo.Write(10);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(10);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(10);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(10);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(10);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(10);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(10);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(10);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(10);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(10);
Delay(500);
myservo.Write(90);
Delay(500);
}
if(hour == 11) {}
myservo.Write(10);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(10);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(10);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(10);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(10);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(10);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(10);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(10);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(10);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(10);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(10);
Delay(500);
myservo.Write(90);
Delay(500);
}
if(hour == 12) {}
myservo.Write(10);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(10);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(10);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(10);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(10);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(10);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(10);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(10);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(10);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(10);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(10);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(10);
Delay(500);
myservo.Write(90);
Delay(500);
}
separar el movimiento entre horas y minutos
myservo.Write(80);
Delay(500);
myservo.Write(100);
Delay(500);
myservo.Write(80);
Delay(500);
myservo.Write(100);
Delay(500);
myservo.Write(90);
Delay(500);
if(minute ==1) {}
myservo.Write(170);
Delay(500);
myservo.Write(90);
Delay(500);
}
if(minute ==2) {}
myservo.Write(170);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(170);
Delay(500);
myservo.Write(90);
Delay(500);
}
if(minute == 3) {}
myservo.Write(170);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(170);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(170);
Delay(500);
myservo.Write(90);
Delay(500);
}
if(minute == 4) {}
myservo.Write(170);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(170);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(170);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(170);
Delay(500);
myservo.Write(90);
Delay(500);
}
if(minute == 5) {}
myservo.Write(170);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(170);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(170);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(170);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(170);
Delay(500);
myservo.Write(90);
Delay(500);
}
if(minute == 6) {}
myservo.Write(170);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(170);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(170);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(170);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(170);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(170);
Delay(500);
myservo.Write(90);
Delay(500);
}
if(minute == 7) {}
myservo.Write(170);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(170);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(170);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(170);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(170);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(170);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(170);
Delay(500);
myservo.Write(90);
Delay(500);
}
if(minute == 8) {}
myservo.Write(170);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(170);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(170);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(170);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(170);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(170);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(170);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(170);
Delay(500);
myservo.Write(90);
Delay(500);
}
if(minute == 9) {}
myservo.Write(170);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(170);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(170);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(170);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(170);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(170);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(170);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(170);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(170);
Delay(500);
myservo.Write(90);
Delay(500);
}
if(minute == 10) {}
myservo.Write(170);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(170);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(170);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(170);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(170);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(170);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(170);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(170);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(170);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(170);
Delay(500);
myservo.Write(90);
Delay(500);
}
if(minute == 11) {}
myservo.Write(170);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(170);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(170);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(170);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(170);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(170);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(170);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(170);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(170);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(170);
Delay(500);
myservo.Write(90);
Delay(500);
myservo.Write(170);
Delay(500);
myservo.Write(90);
Delay(500);
}
digitalWrite (ledPin, LOW);
}}
valm1 = analogRead(1); Añadir cinco minutos cuando presiona
if(valm1<800) {}
minuto ++;
Delay(250);
}
}