12v single channel relay (2024)

"I have a 12V single-channel relay and a 12V solenoid lock connected to an Arduino Mega with WiFi. I want to test the solenoid and relay, but the issue is that the solenoid operates immediately when powered on, instead of waiting to be triggered. Additionally, the relay's indicator light (yellow/green and red) just dims and brightens instead of turning on or off as expected. Ideally, when the relay's light turns off, the solenoid should activate, and when the light turns on, the solenoid should release."

heres my testing code

#define RELAY_PIN 12  // Use Pin 12 for relay control

void setup() {
    pinMode(RELAY_PIN, OUTPUT);  // Set Pin 12 as output
    digitalWrite(RELAY_PIN, HIGH); // Default OFF (active LOW relay)
}

void loop() {
    digitalWrite(RELAY_PIN, LOW); // Turn relay ON
    delay(3000);                  // Wait for 3 seconds
    digitalWrite(RELAY_PIN, HIGH); // Turn relay OFF
    delay(3000);                  // Wait for 3 seconds
}

and the pins

12V Solenoid Lock:

  • to NO of the 12V Relay.
  • to GND of the 12V power supply.

12V Relay:

COM to + of the 12V power supply.
IN to D7 PWM of the Arduino Mega 2560.
GND to GND of the Arduino Mega 2560.
VCC to + of the 12V power supply.

im sorry im newbie guys hope someone help me

Disconnect that right away, you may have damaged the Arduino.
Can you give a website link to the actual relay module you are using?

since i'm from philippines we use shopee or lazada

heres the link were i bought the relay

( https://shopee.ph/1-2-4-8-Channel-5V-12V-10A-Relay-Module-with-Optocoupler-i.18252381.670803085 )

The link requires a login.
Do you have a direct link can you show a picture of the relay module?

Does the module have a Vcc-Jdvcc jumper on it

I don't know. I only know is

Vcc NC
IN COM
GND NO

On the 12v relay

I found thier website (1 2 4 8 Channel 5V 12V 10A Relay Module with Optocoupler – Makerlab Electronics)

Make sure there is 12V written on your relay.
You need common ground. Arduino GND and 12V power supply GND needs to be connected.

Since it is 12V, you will need a transistor driver circuit in order to use that relay or you could buy a 5V relay.
DO NOT connect it to an Arduino.