Control Motores Giro arduino y contador de capsulas
Enviado por Antonio • 5 de Diciembre de 2018 • 1.095 Palabras (5 Páginas) • 505 Visitas
...
if(flag == 0){
Serial.println("Control Giro");
flag=1;
}
}
// if the state is ’R’ the motor will turn left
else if (state == ’R’) {
digitalWrite(motor2Pin1, HIGH);
digitalWrite(motor2Pin2, LOW);
if(flag == 0){
Serial.println("Motor vibracion 1 encendido");
flag=1;
}
}
// if the state is ’S’ the motor will Stop
else if (state == ’S’ || stateStop == 1) {
digitalWrite(motor1Pin1, LOW);
digitalWrite(motor1Pin2, LOW);
digitalWrite(motor2Pin1, LOW);
digitalWrite(motor2Pin2, LOW);
digitalWrite(motor3Pin1, LOW);
digitalWrite(motor3Pin2, LOW);
if(flag == 0){
Serial.println("Parar todos los motores");
flag=1;
}
}
// if the state is ’L’ the motor will turn right
else if (state == ’L’) {
digitalWrite(motor1Pin1, HIGH);
digitalWrite(motor1Pin2, LOW);
if(flag == 0){
Serial.println("Motor vibracón 2 encendido");
flag=1;
}
}
// valor1 = digitalRead(ReceptorMotor1);
// valor2 = digitalRead(ReceptorMotor2);
/*
if (valor1 == HIGH) {
digitalWrite(motor1Pin1, HIGH);
digitalWrite(motor1Pin2, LOW);
}
if (valor1 == LOW) {
digitalWrite(motor1Pin1, LOW);
digitalWrite(motor1Pin2, HIGH);
}
if (valor2 ==HIGH) {
digitalWrite(motor2Pin1, HIGH);
digitalWrite(motor2Pin2, LOW);
digitalWrite(motor3Pin1, HIGH);
digitalWrite(motor3Pin2, LOW);
}
if (valor2 ==LOW) {
digitalWrite(motor2Pin1, LOW);
digitalWrite(motor2Pin2, HIGH);
digitalWrite(motor3Pin1, LOW);
digitalWrite(motor3Pin2, HIGH);
} */ }
void ServicioBoton()
{
if ( millis() > T0 + 250)
{ contador++ ;
T0 = millis();
}
...