HELP! Ideally within the next 24hrs PLEASE!!!!!

We have a simple circuit where we have a button, that when pressed, starts a motor that needs to run at a certain speed for a certain amount of time. (The circuit also involves an infrared sensor that is meant to be counting the wheel spokes as the wheel rotates which will be used to stop the motor after a certain number of spokes however we have given up incorporating this element as we found it too difficult - However, any help on how to do this is greatly appreciated)

Attached are our attempts at coding and the circuit diagram. Any help on coding is massively appreciated. We have an exhibition in a couple of days and can't get it to work.

From a group of mechanical engineering students with zero coding experience Details: Raspberry Pi used, Python used for programming, 12V NiMH rechargeable battery, 84rpm DC motor.


  • 1
    We need text listings of the code in the question. Not photos. Also explain in your question what is not working as you expect.
    – joan
    Jun 3, 2022 at 17:36
  • It is not clear which N-channel power MOSFET you are using. One tip is not to use the very popular NRF540N - Use NRL540N instead. Reference: Power MOSFET Driving Big Motor Problem - Asked 3 years, 3 months ago Modified 1 year, 9 months ago Viewed 928 times raspberrypi.stackexchange.com/questions/94031/….
    – tlfong01
    Jun 4, 2022 at 2:59
  • Troubleshooting tip. As you can see in the schematic diagram of my MOSFET driving motor test referred above. I am using a (10k + status LED) for debugging a short python program which just blinks the LED. You can first test if the LED blinks (without connecting the motor). Only after your Blinky program works, then you connect the motor. Good luck and have anive weekend. Cheers.
    – tlfong01
    Jun 4, 2022 at 3:11
  • (1) I have made public my CircuitLab schematic of IRL540N controlling motor. CircuitLab is the official, free, schematic drawing tool for this Rpi and EE StackExchange. So you can open my public file and edit it, to save some time. But the learning curve of CircuitLab is steep for mechanical enggr students. (2) The URL of my public CircuitLab file is: circuitlab.com/circuit/n7764g3wm5d2/irl540n_motor_2022jun0401. Just click the url and Rpi.SE will start CircuitLab and open the file. (3) I have also cut and pasted a jpg file in Imgur for you: imgur.com/a/dxif3bJ
    – tlfong01
    Jun 4, 2022 at 6:49


Your Answer

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