I think that you shoud/could add also schmitt trigger circuit.Tzarls wrote:What do you think?
Yes that would work with a pull up resistor. The problem with it is that you do not chose the sensitivity. You will only get a high reading if your photo transistor resists more than whatever the pull up resistor resists.Tzarls wrote:Hi. I need to have the pi detect when a light beam is interrupted. For that I wanted to use a phototransistor. I searched the forum to find how to correctly connect it to the Pi, and found this topic:
http://www.raspberrypi.org/phpBB3/viewt ... transistor
After reading it I was left with this idea: If I connect a GPIO pin (configured as input with the pull-up resistor on) directly to the transistor´s collector and the emitter connected to ground, will it work as desired? I guess I could add a resistor between the emitter and ground just in case the pin is accidentally set to output (and HIGH).
What do you think?
Thanks for the suggestion - I guess I need to check the Pi´s schematics in order to understand what you describe! The problem is that the project in hand needs 8 inputs with a photoresistor each and 4 outputs, so there´s no posibility of using this technique. Anyway, I´ll make some tests and hope I don´t blow anything in the process! Thanks again - and if there are some more comments let me know.mahjongg wrote:you can "fake" the hysteresis provided by a schmitt-trigger by inverting what you read from the phototransistor and outputting it on another GPIO, then connecting a resistor from that output GPIO to the photodetector input GPIO. Use a value for this resistor that is a large multiple of the pull-up resistor of the photo-transistor (so if the pull-up is say 10K, use a feedback resistor of say 47K). This will then act as a positive feedback, and give hysteresis to the input, without needing extra hardware, except the resistor.
I guess the DIP versions of the 74HC14 are just as easy, or even easier to buy than the SMT versions:Tzarls wrote:Good idea - now, how do I get an SMD component working with a protoboard? I guess there is a non-SMD version, so I´ll look for it. And while I´m at it, I think I´ll add some buffering to my inputs and outputs, just in case. Or get a Gertboard.