Hi,
I've got a 5 channel flame sensor, a 4 channel relay, 2 water pumps, a breadboard, and a 6 battery power supply. I've wired the power supply to the breadboard and am using it to power the pumps.
The relay and sensor are both connected to the arduino. Problem is, whenever the sensor reads a positive and tries to turn on the relay for the pumps, it bugs out and doesn't do it properly.
Here's the code:
int relay2 = 2;
int relay3 = 3;
int wait = 2000;
const int sensorPin1 = 8; // Digital pin for sensor 1
const int sensorPin2 = 9; // Digital pin for sensor 2
const int sensorPin3 = 10; // Digital pin for sensor 3
const int sensorPin4 = 11; // Digital pin for sensor 4
const int sensorPin5 = 12; // Digital pin for sensor 5
void setup() {
Serial.begin(9600);
pinMode(relay2, OUTPUT); // set relay pins as output
digitalWrite(relay2, HIGH); // turn relay off
pinMode(relay3, OUTPUT); // set relay pins as output
digitalWrite(relay3, HIGH); // turn relay off
pinMode(sensorPin1, INPUT);
pinMode(sensorPin2, INPUT);
pinMode(sensorPin3, INPUT);
pinMode(sensorPin4, INPUT);
pinMode(sensorPin5, INPUT);
}
void loop() {
int value1 = digitalRead(sensorPin1);
int value2 = digitalRead(sensorPin2);
int value3 = digitalRead(sensorPin3);
int value4 = digitalRead(sensorPin4);
int value5 = digitalRead(sensorPin5);
Serial.print("Sensor 1: ");
Serial.println(value1);
Serial.print("Sensor 2: ");
Serial.println(value2);
Serial.print("Sensor 3: ");
Serial.println(value3);
Serial.print("Sensor 4: ");
Serial.println(value4);
Serial.print("Sensor 5: ");
Serial.println(value5);
if ((value1 == 1) || (value2 == 1) || (value3 == 1) || (value4 == 1) || (value5 == 1)) {
Serial.println("Positive detection!");
digitalWrite(relay2, LOW); // turn relay on
delay(5000);
}
delay(wait); // Add a delay to stabilize readings
}
And here are some photos of the wiring(I've only wired one pump to test it):