Soy nuevo en esto y estoy haciendo un proyecto de temporizador con un arduino uno-r3 y un modulo de reveladores
la idea es esta: quiero controlar cuatro electrovalvulas: la Electrovalvula 1 se encendería y se apagaria cada 12 horas, la electrovalvula 2 se encendería y se apagaría cada 5 minutos, mientras las Electrovalvulas 3 y 4 están apagadas.
después de las 12 horas las Electrovalvulas 1 y 2 se apagarían y se haría el mismo ciclo pero ahora con las electrovalvulas 3 y 4 y asi alternadamente.
espero alguien me pueda ayudar, escribo lo que tengo de mi codigo (los tiempos están así por que es el código con el que estoy probando). Gracias.
const int ledPinB = 8; // the number of the LED pin B
const int ledPinC = 9; // the number of the LED pin C
const int ledPinD = 10; // the number of the LED pin C
const int ledPinF = 11; // the number of the LED pin C
// Variables will change:
int ledStateB = LOW; // ledState used to set the LED B
int ledStateC = HIGH; // ledState used to set the LED C
int ledStateD = LOW;
int ledStateF = HIGH;
long previousMillisB = 60000; // will store last time LED B was updated
long previousMillisC = 60000; // will store last time LED C was updated
long previousMillisD = 10000;
long previousMillisF = 10000;
// the follow variables is a long because the time, measured in miliseconds,
// will quickly become a bigger number than can be stored in an int.
long intervalB = 60000; // interval at which to blink LED B(milliseconds)
long intervalC = 60000; // interval at which to blink LED C(milliseconds)
long intervalD = 10000;
long intervalF = 10000;
void setup()
{
// set the digital pin as output:
pinMode(ledPinB, OUTPUT);
pinMode(ledPinC, OUTPUT);
pinMode(ledPinD, OUTPUT);
pinMode(ledPinF, OUTPUT);
}
void loop()
{
unsigned long currentMillis = millis();
//Led B
if(currentMillis - previousMillisB > intervalB)
{
previousMillisB = currentMillis;
if (ledStateB == LOW)
ledStateB = HIGH;
else
ledStateB = LOW;
digitalWrite(ledPinB, ledStateB);
}
//Led C
if(currentMillis - previousMillisC > intervalC)
{
previousMillisC = currentMillis;
if (ledStateC == HIGH)
ledStateC = LOW;
else
ledStateC = HIGH;
digitalWrite(ledPinC, ledStateC);
}
//Led D
if(currentMillis - previousMillisD > intervalD)
{
previousMillisD = currentMillis;
if (ledStateD == LOW)
ledStateD = HIGH;
else
ledStateD = LOW;
digitalWrite(ledPinD, ledStateD);
}
//Led F
if(currentMillis - previousMillisF > intervalF)
{
previousMillisF = currentMillis;
if (ledStateF == HIGH)
ledStateF = LOW;
else
ledStateF = HIGH;
digitalWrite(ledPinF, ledStateF);
}
}