C code:
#define RELAY_ON 0
#define RELAY_OFF 1
#define Relay1 2
#define Relay2 3
int estado=0;
boolean replay = true;
void setup()
{
Serial.begin(9600);
digitalWrite(Relay1, RELAY_OFF);
pinMode(Relay1, OUTPUT);
digitalWrite(Relay2, RELAY_OFF);
pinMode(Relay2, OUTPUT);
}
void loop()
{
if (Serial.available()>0)
{
estado=Serial.read();
}
if (estado == '1')
{
replay = true;
}
if (estado == '2' ) //Button state "OFF" in the android app
{
if (replay == true)
{
digitalWrite(Relay2, RELAY_ON); //Valve opens
delay(10000); //time that took the water to get to the conatainer
digitalWrite(Relay2, RELAY_OFF); //Valve closes
digitalWrite(Relay1, RELAY_ON); //Resistor On
delay(240000); //time that took the coffee to get ready
digitalWrite(Relay1, RELAY_OFF); //Resistor Off
replay = false;
}
}
}
Fab Academy 2019- Final Project from Silvia Lugo on Vimeo.