HI,
I hope I am posting on the right section and in the correct way. I am bit of a beginner in the wonderful realm of Arduino and have put together a few model railway signalling related projects that have been very succesful.
I am now attemping to put together a small project that controls two pumps in two large containers that hold rain water for a paiir of flower beds. I have got this all working - it is very simpe based around two float switches and a 2 gang relay module.
It would be really useful to put a timer onto the project so that everything goes LOW(off) after say 10 minutes. This is really a bit of a failsafe to prevent pump burnout in case of float switch failure.
I have searched the web for timer examples and millis() seems to be the answer but the examples all seem very complicated I just can't get the code to work. Adding a button to start the cycle would be excellent as well although simply switching off the power supply works just as well.
I have added my code below and I would be really grateful if someone wld be kind enough to point me in the right direction.
Many thanks,
Mike Andrew
// Dual Water Pump Float Valve Unit
//v1.0 - One pump working
//v1.1 - Two pumps
//v1.2 - Reorganise Pinouts - working Version
#define FLOAT1_SENSOR 3
#define RELAY1 4
#define LED1_R 5
#define LED1_G 6
#define FLOAT2_SENSOR 7
#define RELAY2 8
#define LED2_R 9
#define LED2_G 10
void setup()
{
// initialize the pins:
pinMode(LED1_R, OUTPUT);
pinMode(LED1_G, OUTPUT);
pinMode(RELAY1,OUTPUT);
digitalWrite(RELAY1, LOW);
pinMode(FLOAT1_SENSOR, INPUT_PULLUP);
pinMode(LED2_R, OUTPUT);
pinMode(LED2_G, OUTPUT);
pinMode(RELAY2,OUTPUT);
pinMode(FLOAT2_SENSOR, INPUT_PULLUP);
}
void loop()
{
//Float Sensor 1
if(digitalRead(FLOAT1_SENSOR) == LOW)
{
digitalWrite(RELAY1, LOW);
digitalWrite(LED1_R, LOW);
digitalWrite(LED1_G, HIGH);
}
else
{
digitalWrite(RELAY1, HIGH);
digitalWrite(LED1_R, HIGH);
digitalWrite(LED1_G, LOW);
}
//Float Sensor 2
if(digitalRead(FLOAT2_SENSOR) == LOW)
{
digitalWrite(RELAY2, LOW);
digitalWrite(LED2_R, LOW);
digitalWrite(LED2_G, HIGH);
}
else
{
digitalWrite(RELAY2, HIGH);
digitalWrite(LED2_R, HIGH);
digitalWrite(LED2_G, LOW);
}
}