Ground triggered relay output as input to Arduino

Hi everyone, I am new to the forum.

I have a relay that has a ground trigger, that is supposed to output 5V to the Arduino when triggered. The issue is that, since the switch is not grounded until it is closed, this means that I have a floating input when it is open. Thus when calling analogRead, I get a high value regardless of whether the relay is open or closed. Suggestions? Would calling pinMode(INPUT_PULLUP) solve the issue, or would I need some additional component? I am using an Arduino Leonardo by the way.

You might want to post a schematic. One side of the relay contact needs to be connected to ground and the INPUT_PULLUP would be on the pin connected to the other side of the contact. When the relay is on you will get a low and when off you will get a high. I hope this answers your question.

Basically we have no idea what you are talking about.

Details are required. :astonished:

Would calling pinMode(INPUT_PULLUP)

I suggest you try it and see.

You don't need analogue read for detecting the state of a relay contact.

Post a link to the datasheet or product page of the thing you are talking about, we
cannot read your mind!

But yes, if the relay is just playing the role of a push-button, you need a pullup,
internal or otherwise, always...

Define, "trigger", "triggered".