This circuit is designed to control water pumps for an artificial flower setup using an Arduino UNO. The system includes water level sensors to monitor the water levels and relays to control the pumps. The Arduino UNO reads the sensor data and activates the pumps at regular intervals to dispense water.
Water Level Sensor
Arduino UNO
Water Pump
5V Relay
9V Battery
// Pin Definitions
const int flower1PumpRelayPin = 2; // Relay for pump 1 (Artificial Flower 1)
const int flower2PumpRelayPin = 3; // Relay for pump 2 (Artificial Flower 2)
// Timing Variables
unsigned long previousTimeFlower1 = 0; // Last time flower 1 pump was activated
unsigned long previousTimeFlower2 = 0; // Last time flower 2 pump was activated
const unsigned long interval = 10000; // 10 seconds interval for nectar dispensing
void setup() {
// Set pump relay pins as OUTPUT
pinMode(flower1PumpRelayPin, OUTPUT);
pinMode(flower2PumpRelayPin, OUTPUT);
// Initialize relays to OFF state (HIGH for active-low relays)
digitalWrite(flower1PumpRelayPin, HIGH);
digitalWrite(flower2PumpRelayPin, HIGH);
}
void loop() {
// Get the current time in milliseconds
unsigned long currentTime = millis();
// Flower 1: Check if 10 seconds have passed since the last nectar dispense
if (currentTime - previousTimeFlower1 >= interval) {
previousTimeFlower1 = currentTime; // Update the last dispensing time
// Turn on the pump for Flower 1 briefly to release a drop
digitalWrite(flower1PumpRelayPin, LOW); // Turn ON pump for Flower 1
delay(300); // Pump runs for 300ms
digitalWrite(flower1PumpRelayPin, HIGH); // Turn OFF pump for Flower 1
}
// Flower 2: Check if 10 seconds have passed since the last nectar dispense
if (currentTime - previousTimeFlower2 >= interval) {
previousTimeFlower2 = currentTime; // Update the last dispensing time
// Turn on the pump for Flower 2 briefly to release a drop
digitalWrite(flower2PumpRelayPin, LOW); // Turn ON pump for Flower 2
delay(300); // Pump runs for 300ms
digitalWrite(flower2PumpRelayPin, HIGH); // Turn OFF pump for Flower 2
}
}
This code sets up the Arduino to control two water pumps, each connected to a relay. The pumps are activated every 10 seconds to dispense water for a brief period. The relays are controlled using digital pins on the Arduino, and the timing is managed using the millis()
function to ensure non-blocking delays.