Controlling Simple Relay Circuit

Hi,

I am pretty new to all this and need some help.

I want to have a simple relay circuit to open/close every second. I am assuming that this is wired right, if not please let me know.

I have the IN2 plugged into spot 2 on the board in case it is hard to see.

So basically all I really need is some sort of simple code to put on the board and have just constantly repeat.

Thanks

EDIT:
Would this work? I currently do not have a power source so I am not sure if it works as I do not hear any clicking

int outPin = 2;

void setup()
{
  pinMode(outPin,OUTPUT);
}
  void loop()
  
  { 
    digitalWrite(outPin,HIGH);
    delay(1500);
    digitalWrite(outPin,LOW);
    delay(1500);
    
    
  }

looks like it should work.

the delay of 1500 is a second and a half.
not sure how close to one second you want to be.

i

dave-in-nj:
looks like it should work.

the delay of 1500 is a second and a half.
not sure how close to one second you want to be.

i

The timing is not a big issue for me. Do I need a transistor in the circuit at all? I have read that it is needed.

Also, the light on the relay board goes on an off every 1.5 seconds, But there is no click. Do I need an actual power source and light before I will hear the click or should it be working before I add the external device and supply(light and 110v)

Generally, you need to look at the specs of your relay and see either what the resistance is or the coil current. If it’s >20mA or <250 ohms, then you need one.

However you have a “relay module” there and that has your transistor built in. If I recall correctly, they are opto-coupled and are expecting a “low” to turn them on. Either way your code should work once you get your power source connected. You will need to connect the relay board’s GND to the Arduino’s GND, don’t forget. You also want to be careful on what you hang on the Arduino’s 5V output if that’s how you’re powering your relays.

Hi,

As rmetzner49 said! I can confirm that's how they work, or at least the one's I have, which are more or less the same looking as yours. Always think it a bit back to front to have to use a LOW to switch something ON! They are opto-coupled so safe and of course have a diode across the relay coil to protect the drive transistors.

Hope it helps, regards

Mel.