Hi! Ive been trying to make this 12v relay work but cant seem to make it work. Been searching for all the possibilities on how to make this work online but no luck. Hope someone can help me, below are the code, rough diagram, and the 12v 4 channel relay module photo.
const int relayPin = 13; // Pin connected to the relay
void setup() {
pinMode(relayPin, OUTPUT); // Set relay pin as output
}
void loop() {
digitalWrite(relayPin, HIGH); // Turn on the relay (and the fan)
delay(3000); // Wait for 3 seconds
digitalWrite(relayPin, LOW); // Turn off the relay (and the fan)
delay(3000); // Wait for 3 seconds
}
With that type relay board, with 12V relays, you need to remove the jumper on the 2-pin header labeled JD-VCC / VCC. The 12V power supply for the relays is connected to the JD-VCC pin and the GND pin on the 6-pin header. The VCC pin on the 6-pin header connects to the 5V pin on the Arduino, the IN1/IN2/IN3/IN4 pins connect to the Arduino pins that are controlling the relay, there is NO connection to GND on the Arduino. A LOW output on the Arduino pin will turn the relay ON, a HIGH output will turn the relay OFF.
You do not need a connection from GND of the relay board to GND of the Arduino. The relay board input is opto-isolated, the Arduino is controlling an LED inside the opto-coupler, that LED is connected through a resistor to Vcc and turns ON when the input from the Arduino is LOW.