Hi
I am trying to write a program for Arduino. I have two inputs (Full and empty) and to solenoids to activate. In case the full input is on, the bottom solenoid should be activated until the empty input is on. Then, the upper solenoid should be activated and the bottom should be deactivated, until the full input is on again. It should run in a loop for 10 times and stop.
Can you help me with that??
Well here's a little to get you started:
#define WAITING 0
#define DRAINING 1
#define FILLING 2
int cycles_to_go = 10 ;
int state = WAITING ;
void loop ()
{
if (cycles_to_go > 0)
handle_tank () ;
}
void handle_tank ()
{
if (digitalRead (full_pin))
{
digitalWrite (drain_solenoid. HIGH) ;
digitalWrite (fill_solenoid, LOW) ;
state = FILLING ;
}
else if (!digitalRead (empty_pin))
{
digitalWrite (drain_solenoid, LOW) ;
digitalWrite (fill_solenoid, HIGH) ;
state = DRAINING ;
}
...
}