I'm building an electronic gate. I'm needing a photoelectric sensor to detect cars. This one in the link looks decent. it runs on 12v so I will need to power it separately from the arduino. But does this mean it also puts 12v back to the signal wire? Will that work with ardunio without burning the circuit? How many V can i send into an arduino pin?


photo electric sensor

  • Some arduino boards use a 5v microcontroller, some use a 3.3v processor. The input voltage may not be above that. You have to use a few electronic components to fix it. It depends on the output of the detector, but two resistors to lower 12v to 5v is the most common solution. Search for: voltage divider arduino.
    – Jot
    Dec 8 '18 at 17:06
  • I'm not sure what I will end up with, but the one i have now is a arduino uno made by keyestudio. I'm not sure if it means anything but there is a 3.3 and a 5 v power supply from it. Sorry, i'm kinda new at this. but using resistors to drop the voltage does seem like a pretty good solution.
    – birddseedd
    Dec 8 '18 at 17:09
  • Edit your question to add the information that you're using the Keyestudio Uno. The question should contain all the necessary information rather than having to hunt through the comments for it.
    – per1234
    Dec 8 '18 at 22:59

The sensor you specified states:

Output: SPDT Relay Output

If accurate, it may be inferred that the output is simply 3 contacts where one is normally open and the other is normally closed and the 3rd is the common. If true then you can treat the output as if it were an ordinary Single Poll Double Throw (SPDT) switch. Note, with regard to processors, an ordinary switch may need to de-bounced. This depends on how the state of the switch is used.

  • to my understanding that's basically it. there is a relay inside the sensor and hte sensor just sets off the relay. i should be able to run 5v to it and just listen for that 5v to go to pin2
    – birddseedd
    Jan 11 '19 at 15:20
  • When connected to 5V the input to the arduino should be 5V. But what is the input when not connected? When the relay is open? Ah, this is where you need a pull down resistor. So as not to allow the arduino's input to float to an unknown voltage.
    – st2000
    Jan 12 '19 at 4:54
  • yes possibly. the arduino is supposed to have that built in. maybe my off brand arduino doesn't. I had to build my own pull down. but the instructions were pretty clear. just grounding a resistor. When i get my hands on the sensor ill be able to tell if itl work or need the resistor.
    – birddseedd
    Jan 13 '19 at 5:10
  • Truth is, many embedded processors have the ability to program in a pull up or even a pull down resistor. I didn't want to go that route as explaining the details requires more than what we do here in a stackexchange comment section. In addition, these pull up / down resistors are usually weak by design and may not exist on all pins. Finally, by using a SPDT switch that breaks before makes (most do) and making sure the wiring is correct (we don't want to short out the power supply!!) we can force the digital input both high and low w/o using a resistor. But do double check the wiring!!
    – st2000
    Jan 13 '19 at 17:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.