Using a relay with an arduino

Hi,
So I am trying to use a relay to control some electromagnets, however I seem to be running into a couple of issues. I am using an Arduino R3, with an 125VAC 5 A Relay, and a 90 volt power supply with an electromagnet. I was following this turtorial: https://arduinogetstarted.com/tutorials/arduino-relay
And I have essentially the exact same wiring as shown near the end of the webpage. However, pasting their code, and recoding it myself, and switching pins doesn't seem to get the relay to work. The relay however, does seem to be receiving commands from the arduino, an onboard light shines green as progrtammed every half a second, showing it is receiving the "high" command, however it does not seem to excute it. Replacing the relay yeilds a simlar story. Does anybody have any resolutions or suggestions? Thanks.

Code:

int RELAY_PIN = 3; 

void setup() {
  pinMode(RELAY_PIN, OUTPUT);
}

void loop() {
  digitalWrite(RELAY_PIN, HIGH);
  delay(500);
  digitalWrite(RELAY_PIN, LOW);
  delay(500);
}

Ninety volt power supply?

It's adjustable (up to 120), have it set at 90 right now, using the power supply instead of using a capicitator for the electromagnets.

90V switched through the relay contacts?
(They may have welded. 120VAC contacts does not necessarily mean 90VDC ok.)

Ah ok. However 30 volts and 20 don't work either

Welding is permanent.

So you're saying the wires welded into the relay switches? That doesn't seem to be the case

No, the contacts inside are stuck together.
Remove the 90V and just try to click the relays. Your sketch looks appropriate for that much. Any click-clack from it?

I agree that the relay contacts are probably welded together, or if not, permanently damaged.

Switching DC with a relay is very different than switching AC, especially with an inductive load like an electromagnet.

For simple on/off control a suitable logic level MOSFET or DC Solid State Relay would be a better choice. An inductive kick suppression diode is required, as shown below:

I'm sorry, however how would I do this? Thanks

Understood. I have a couple MOSFET's that I'll try

I would strongly recommend using a DC SSR instead.

It is very dangerous to mix high (50V or greater) and low (3.3 or 5V) voltages. But if you insist on using a MOSFET,

  1. Make sure it is rated for 200V or higher drain voltage, and at least twice the maximum current required by the load.

  2. Use a custom PCB, NOT a breadboard, as the breadboard connectors will burn.

  3. Use an optocoupler to isolate the gate connection from the Arduino, otherwise you might fry the Arduino, your computer, and yourself in one short and violent event.

Example circuit below (the details will all be different):

Capture

Well, what are we talking about here?

Don't run the 90V supply to the relay board / circuit.
Just run sketch with the arduino connected to the relay board, listening to how the relay goes click-clack (or not). Maybe increase time to 1 sec or more.

Yeah I messed up with this(the relay). I read the specs further, turns out (well, I believe) it can handle both AC and DC but DC's up to 30 volts. I think I'll test another relay and see if it works at 24 volts.

Hmmm I don't believe I hear anything

Because the contacts are -- stuck.

Odd. I opened up another relay. Ran the code (without any powersupply.) Red light stays on - constant. Green light flashes. No click.

Time to show your circuit, pics, etc.

Yup here:

Red light as shown stays on all the time, green flashes, relay is connected correctly to 5 volts, ground, and pin 3.

24V coil requires a 24V supply.