Cant figure out why relay wont work

So I have a high/low level trigger single channel relay that I am using for a project and it wont seem to send voltage through it. I am using the 5v pin to supply power to the relay and the breadboard with the button (project) works great, however, I cannot get voltage through the contactor to save my life. Here is the code that I am using to allow the button to control the relay:

int buttonApin = 9;
int relay = 6;
boolean flag = true;

void setup() {
pinMode(6, OUTPUT);
pinMode(buttonApin,INPUT_PULLUP);
}
void loop()
{
if (digitalRead(buttonApin) == LOW){
delay(5);
flipflop();
}
}
void flipflop(){
flag = !flag;

if(flag == HIGH){
digitalWrite(6,HIGH);
}
if(flag == LOW){
digitalWrite(6,LOW);
}
while(digitalRead(buttonApin)==LOW){
delay(50);
}
}

I read somewhere that you cant use these relays with low voltage but I purposely bought a low level trigger. I even cut up an old power supply and gave it 24v, still nothing. I have continuity with the NC part of the relay but no voltage. I have been on this for hours because it just doesn't make sense.

What relay? And can you put your code inside < /CODE> tags after using Ctrl +T in the IDE please. Makes it easier to read.

Help us help you.

My apologies that was the first time that I have ever posted code as I am very new to the forum. Wont happen again and thank you for letting me know the proper way.

I dont know what simulator code is but it is what I am using in the IDE to achieve using a button to control the relay. The code works just fine but the relay isnt and I am wondering if its something in the code but i figured it was just mechanical

Is there a preferred program that yall use to create schematics?

int buttonApin = 9;
int relay = 6;
boolean flag = true;


void setup() {
  pinMode(6, OUTPUT);
  pinMode(buttonApin, INPUT_PULLUP);
}
void loop() {
  if (digitalRead(buttonApin) == LOW) {
    delay(5);
    flipflop();
  }
}
void flipflop() {
  flag = !flag;

  if (flag == HIGH) {
    digitalWrite(6, HIGH);
  }
  if (flag == LOW) {
    digitalWrite(6, LOW);
  }
  while (digitalRead(buttonApin) == LOW) {
    delay(50);
  }
}

Just trying this out, thanks for the heads up

Your relay might need a 5vdc power supply on the (+) and (-) pins to drive the coil. Your code works. Try using a multimeter at the relay pins where you have the orange jumper wires.

1 Like

So ive tried 5v from the arduino, 9v battery from arduino kit, 12v, and 24 volts from an old charger I cut and attached. If I use a multimeter I have 5v at the DC+ to DC - and also 5v between IN and DC -. I have continuity between the NC and COM when relay is not on and continuity between NO and COM when relay is on, yet my voltage [DC and AC] isnt present.

The only thing i can think of is that I pulled the high/low voltage jumper off and changed it while the relay was powered and maybe damaged it? Or I was sold bad relays...

Sounds like the relay is working, can you show the wiring on the contact side of the relay? How are you supplying voltage to the relay contacts, and what kind of load are you controlling?

I do not have any wiring on the contact side of the relay because I have no voltage present across the contact. When I check with a multimeter there is no 5v present on the contact side so I didnt bother wiring anything up. I did try to put dupont wires in the contact side and checked to see if there was voltage but there wasnt.

I tried hooking up a 5v water pump to the contact side and nothing..

The relay contacts are just a switch, controlled by a magnetic coil. The is no connection at all between the voltage driving the relay coil and the contacts. You have to supply a voltage to the relay contacts (generally to the COM contact), which is then connected to the load through either the NC or NO contact.

So ive been doing this backward? I thought that the 5v from the side i have hooked up would supply the voltage to energize the coil therefore closing the contact and supplying voltage through the relay?

So basically i am just powering the relay right now ? When i press the button the relay clicks as if its making contact

It has been mentioned several times that you need to provide power to the center contact of the relay so that the N.O. side of the contact can provide power when the relay is energized.

Damn, Ive been looking at this all wrong. Thats what they meant by power supply in the earlier posts. I thought they meant on the side I have hooked up now.. makes sense now.

see how power for the coil is not connected to the relay contacts? Power does not just jump to where you want it.

Okay okay I see that. So maybe you can help me understand this.. so how would I wire up some sort of load to the relay? Sorry I am extremely new to this.

Having a hard time visualizing how youd get something with higher voltage to hook up to the relay.

power into the center contact of the relay, wire from the N.O. contact of the relay to the load.

As has been explained, the relay contacts is like a switch. The relay contacts are isolated from the coil V's.

1 Like

Okay this makes a lot of sense. I was thrown off by common but it looks like i only use + and - and complete the circuit.

Ill try it with low voltage first then move up lol

I breezed through this and didnt see you gave me the answer lol. Also thank you for that app to create schematics, that is cool.

1 Like

Thanks for your help man you broke it down for me I appreciate that

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.