I'm asking you for advice to bridge the electronic sides of my project. Two light barriers will be polled for objects passing the lights, when an object passes and triggers a barrier, the barrier provides +12V on one of it's connections. The Arduino is programmed to watch for +5V on two pins.
What I need to know is a simple and reliable way to feed those two +12V signals into the Arduino. Done directly, it would damage the Arduino.
One way could be using two standard 5V regulator circuits (one circuit for one light barrier) based on a 78m05 and three capacitors, which should regulate the 12V (object detected) down to 5V.
One way could be using two standard 5V regulator circuits (one circuit for one light barrier) based on a 78m05 and three capacitors, which should regulate the 12V (object detected) down to 5V.
This is a classic beginners mistake. Do not use voltage regulators for signal voltage level translation.
Simply use two resistors in a potential divider to get the 12V down to 5V.
Regulators are used to power circuits not for voltage translation of signal lines, the regulator would most likely try and draw too much current from your signal source. What you can use is a simple two series wired resistor voltage divider, where the 12vdc signal wires to the top resistor the bottom resistor wires to ground of both the signal source and the arduino. The junction of the resistors would wire to a arduino digital input pin. a 10k ohm top resistor and a 5k ohm bottom resistor would result in a 4vdc signal avalible at the junction of the resistors suitable to wire to the arduino.
Mike, Lefty, thanks for your swift answers.
I'm glad to read that the solution is by far simpler than I thought. Lefty, are 4V (as opposed to 5V) enough to provide a stable digital high on the pins? Would you advise to apply a 10k? pull-down resistor as recommended
No pull-down resistor required, the voltage divider is also acting as a pull-down as the lower resistor is wired to ground and is why the arduino ground must wire to the divider and signal source's ground. As far as what a legal HIGH voltage is the AVR data sheet says minimum voltage for a HIGH is .7 X Vcc, so with an arduino 5volt board the value is 3.5vdc to 5.5vdc.
retrolefty:
No pull-down resistor required, the voltage divider is also acting as a pull-down as the lower resistor is wired to ground and is why the arduino ground must wire to the divider and signal source's ground. As far as what a legal HIGH voltage is the AVR data sheet says minimum voltage for a HIGH is .7 X Vcc, so with an arduino 5volt board the value is 3.5vdc to 5.5vdc.
Lefty
Actually for the supply voltages used in Arduinos the input thresholds are 0.3Vdd and 0.6Vdd (ie 1.5V and 3.0V for a 5V supply). In particular 3.3V will reliably be recognised as high. These values apply to normal I/O pins (not Xtal or Reset) and only if the supply is 2.4V or greater.
patrick:
Good to know! Can this be found on the Arduino playground? If not, it should be pinned here or elsewhere.
These specifications (along with many many more) are from the AVR datasheet for a 328p chip, of which every Arduino user should download a copy to have avalible at all times.