Motor Pi
This post is all about getting DC or stepper motors working with the Raspberry Pi 3B. Which opens up your pi with the possibilities of say, cars or drones or anything with wheels and/or propellors. 😉
Hardware
The ultimate kit contained in the link has everything you could ever want for your foreseeable future with the raspberry pi. Not necessary to get the full kit but it DOES come in handy.
The adafruit motor shield for the raspberry pi computer:
Modular, stackable hat to give the raspberry pi the ability to efficiently control 4 DC motors or 2 stepper motors. It needs a bit of soldering to get it up and running.
A DC- USB adaptor and some male-to-male wire (Also comes with the raspberry pi starter kit) to connect your power source to the shield.
Uxcell RC toy coreless DC motors and/or DD dcmotors/wheels(need soldering) depending on your intent but for this example, I’ll use both.
This thing is not limited to just those two types of motors so it’s worth it to go look for the ones that are perfect for your project.
Refer back to the overview for more hardware/software installation details.
Code
and once you have got DC motors installed and your all powered up, using the official adafruit python library in the examples folder run DCtest.py or if you’d like, you can use this code which I modified from the original to be a simple motor controller in python3.
It’s missing accel/decel functions and stepper motor use but it’s simple enough to figure out.
With it, you can Control one or all motors, adjust speed, clockwise and counter-clockwise movement.
Sick!
If the motors are not spinning the way you’d like them to, reinstall them but with the wires flipped.
I thought I’d take an overzealous step forward and see if I could get it to fly so I printed out this microquad frame and reduced its dimensions by 15% and attached the Uxcells..
Heh results are expected but I would of loved to have it hover at least..ya know, I feel like if I attached a balloon, I could probably get a blimp out of it..
But you get the idea.
Unplugged pi!!
When your comfortable at this point, you may wanna look into making this thing more self sufficient and sleek. Your not going to want something with wheels to be plugged into the wall for power. You’ll want to add things like travel batteries, an on/off switch etc. More on portability upgrades here.
Likewise, you wouldn’t want to keep it plugged to a monitor to be able to control your machine. Realvnc is an app that let’s you control your Raspberry Pi wirelessly through your mobile phone.
Ok! You now have pretty much everything you need to get the Raspberry Pi motor friendly 🙂
Spend some time getting to know the system and finalizing your package and when everything looks satisfactory, all you’ll need now is a good idea and a frame of some kind for some REAL testing and idea manifesting.
Me, I went for an AWESOME car (as I couldn’t get a drone going yet) and it’s since become a favorite of mine. 😉
Check out my Motorbliss Car!
Ping if you dig it. Comment if you have any questions.
Cheers!
PS: My project you starred has nothing to do with Pygame Zero. But it’s great reference material, because Pygame is extremely easy to use anyway!
Oh that’s fine. Ya know, I kinda suck at pygame so anything I can reverse engineer is totally useful. The plan is to make a GUI for my a.i. that resembles a 2d game. And even has animations that represent whatever task it’s fulfilling. Combining that with say sensor boards, motor boards and servos…
So yea thanks a lot! The gravity/physics thing is what got me.