Python code not working: Programming a motor to turn on using a switch (Raspberry Pi)

Python code not working: Programming a motor to turn on using a switch (Raspberry Pi)

Ask Question

Asked today

Modified today

Viewed 16 times


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.




EditFollowClose 2Flag

edited 8 hours ago

asked 9 hours ago

user avatar


1122 bronze badges

 New contributor

  • 1We need text listings of the code in the question. Not photos. Also explain in your question what is not working as you expect. – joan 9 hours ago
  • group of female mechanical engineering students … female is irrelevant … that should say group of mechanical engineering students – jsotola 8 hours ago 
  • please, no screenshots of text … copy and paste the text itself – jsotola 8 hours ago
  • 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 2 mins ago  Edit  

Add a comment

Categories: Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.