Reading a 12v pulse sensor with Arduino

Hi,

This is actually my first post and first question, so not sure if I'm doing this right. I'd like to read out a pulse coming from a 12v signal wire. (Coin acceptor)

Sending the 12v directly in isn't a great idea, and as a programmer I'm not really sure how to solve this "hardware issue". :smiley:

I read about a voltage divider, and I'm fairly certain I've got that set up. Is there any downside to the schema in the image below? Any caveats? Trying to keep this simple.

Thanks in advance for your advice.

The voltage divider is OK, with ratio = 4.7/(6.8+4.7) = 0.41, so 12V will actually be read out as 4.9V. However, the switch should break the positive connection, not ground.

Otherwise the Arduino input could in some cases be floating and give false readings.

Sending the 12v directly in isn't a great idea

That would instantly destroy the Arduino.

1 Like

Thank you! That helps a lot. Iโ€™ll get started on the real deal then. I was thinking of simply using digitalRead() with INPUT_PULLUP. That would mitigate the false readings. Am I correct?

Do NOT use INPUT_PULLUP, just use INPUT.
The pullup will add a third resistor in the circuit connected to 5V. You don't want to do that.

Are you sure it outputs a 12V pulse. Some require an external pullup resistor than can be connected to 5V, so no need for a voltage divider

Dear Jim,

Thank you for your time and advice. Right! Wonโ€™t do that.
Yeah, it says on the box that it outputs a 12v signal. Can also configure the pulse time with some switches (e.g. 50ms, 100ms)

I think I can manage to code the false positives out programmatically then.

Hello theramon

Use an optocoupler simply.

Hello Paul. I had never heard of those, that seems like a smart way to switch a circuit. Iโ€™ll order a few of those and have a try. Fun!

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