Please help:

I am building a photogate. I was looking for help in building a circuit for the Raspberry Pi 2.

A little background:

I am still a highschool grade 12 student! and I have a basic understanding of circuits as we have not even started electronics and so that is why, I absolutely have no idea how phototransistors change current and so that is why, I have no idea what would the answer be. Also, I am semi sure of how multiple branches affect the current and voltage and resistance. Sorry! I am building this for my Physics IA. Going a little stronger. I will appreciate help or the circuit but if possible, I will appreciate any form of knowledge I can gain.

Design objectives:

What I am looking to build is a simple circuit which has one lead going to input of the GPIO board. One lead to ground and one lead to either 3.3V or 5.0V on the GPIO board, I have no idea how to select which voltage to use. The circuit would have a ir phototransistor that when dark would give an input in raspberry pi GPIO input of 2.0 volt-3.3 volt and 0.0v-1.0 volts when light. I can use any resistor. I want to build the most basic circuit that can give me these inputs when dark and when light. Thanks A lot. Please ask for clarification if needed.

PS. this is a question to build a circuit whereas the other question is about input values from a pre-existing circuit.

  • \$\begingroup\$ Possible duplicate of Circuit changes, what is the input high and low given when the circuit is lit and not! \$\endgroup\$
    – Passerby
    Nov 27, 2015 at 7:12
  • \$\begingroup\$ Also, all Raspberry Pi inputs are 3.3V only. Never connect 5V to a GPIO directly. \$\endgroup\$
    – Passerby
    Nov 27, 2015 at 7:13
  • \$\begingroup\$ This is actually a new question, that circuit did not work and so i am trying to build a newer circuit. This time, i will have two circuits operating, one with the ir led that i can build myself as it is super simple and one with the ir phototransistor that i need help with. The phototransistor when lit will give an input of 0.0-1.0 volts at the GPIO input and 2.0-3.3 when dark. \$\endgroup\$ Nov 27, 2015 at 7:21
  • \$\begingroup\$ The 3.3V vs 5.0V is the source, not the input. And i wouldn't connect a 5.0V to input. What I mean is which one should I use as the source for my circuit. \$\endgroup\$ Nov 27, 2015 at 7:24
  • \$\begingroup\$ That circuit is a standard phototransistor setup. There is no reason it shouldn't work unless you didn't wire it right or the schematic you provided was wrong. \$\endgroup\$
    – Passerby
    Nov 27, 2015 at 7:26

1 Answer 1


Basic setup. Two "circuits". The LED can be powered by a battery or from the RPi's 5V. R-LED should be calculated for the LED you use.


simulate this circuit – Schematic created using CircuitLab

  • 1
    \$\begingroup\$ ahh, thank you so much! I assure you, i won't simply use the circuit but learn from it :) \$\endgroup\$ Nov 27, 2015 at 8:22
  • \$\begingroup\$ I wonder if Q1 can pull the pin low enough. You may need another transistor (a normal one) to amplify the signal. Check with a voltmeter how low it goes. \$\endgroup\$ Nov 27, 2015 at 9:52
  • \$\begingroup\$ If Q1 can't pull low enough, simply increase R2 (perhaps 100 kilohms) \$\endgroup\$
    – user16324
    Nov 27, 2015 at 10:32
  • \$\begingroup\$ @PauloSoares 3.3V and 10kΩ means just 0.3mA. Any common phototransistor can do that easy enough, enough to pull the GPIO node to mostly ground. \$\endgroup\$
    – Passerby
    Nov 27, 2015 at 10:58
  • \$\begingroup\$ That's electronic schematic convention. Typically I would just use the ground symbol, but in this case I explicitly named it as connecting to the RPI ground. It's redundant. Just connect the emitter to ground. \$\endgroup\$
    – Passerby
    Nov 27, 2015 at 21:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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