1. raspberry pi;
  2. level shifter 3V in 5V out;
  3. motor driver (H bridge L293D chip = op amp with diodes to protect inductive kick on power off);
  4. solenoid valve;


  1. GPIO23 on raspi is an output connected to input pin1 of level shifter;
  2. level shifter raises pin1 3.3V signal high to 5.0V signal high on output;
  3. output of level shifter connected to input of motor driver which amplifies current;
  4. output of motor driver powers solenoid;


output of GPIO23 sends current in parallel across; (a) led and current limiting resistor (in series); (b) input to level shifter;


output of level shifter sends current in parallel across; (a) led and current limiting resistor (in series); (b) input to motor driver;


output of motor driver sends current in parallel across; (a) led and current limiting resistor (in series); (b) solenoid valve;

I learned op amps but I do not remember that well;

It's a WHITE diode with Vforward = 3.3V which is as high as a GPIO pin output so you can not run it directly from the GPIO output. The source voltage has to be higher than Vforward. So OPTION1 does not work.

Likewise you can't directly read the output of the level shifter pin 1 and put an led in parallel with the input for the op amp; do not assume the output of the level shifter can supply that much current;


How do you use hardware to use a led light to get the status of GPIO23 ? I think due to the nature of op amps you COULD use OPTION3 because whatever current it draws the op amp could supply; is this solution good ?

The op amp output voltage Vamp should be the Vcc2 on the op amp which is 12V (it uses 5V logic); and a good current for the diode should be 15 mA then the current limiting resistor for the led would be R = (Vamp - Vforward) / 15 mA = 500 ohm;

Is Vamp the same as Vcc2 and it just supplies the requested current at that voltage ? If I remember that's what op amps do.


Another proposed solution is to connect the output of the level shifter (in parallel with the input to the motor driver) to the base of a transistor to amplify that output and power the LED (a so-called "led driver"); The supply voltage of the transistor would be 5V; the LED and a current limiting resistor in series would be between the 5V and the collector of the transistor. The base of the transistor hardly draws any current so it would not interfere with the input to the motor driver;


2 Answers 2


solution with transistor on ouptput of SN74AHCT125 level shifter

Transistor circuit analysis is in text box on bottom right;


same thing as a circuit diagram

Currents and Voltages labeled on circuit diagram. The SN74AHCT125 on the left is the level shifter. The L293D on the right is the motor driver. It has diodes included to protect from inductive kick. Inductor energy in solenoid or motor is dumped when it is shut off and diodes allow energy to escape to ground without damaging attached devices. Instead of putting led on output of motor driver use a transistor "driver" for led. The base current i_b of the transistor does not interfere with the connection from the level shifter to the motor driver since i_b is so tiny. It is also not good to power a white led directly off a GPIO pin in case it draws a little too much current.

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.