A BrickPi3 newbie here with - I hope - a simple question:
Is there a Reference document fur using the BrickPi3 with Python? The examples (at Dexter/BrickPi3/Software/Python/Examples) are ok, but I really just want the basics to learn how to move the motors backwards and forwards, for a specified length of time, at a certain power level.
If there is a ‘crib sheet’ - like this one for PiStorms - that would be great!
Hello @stucro and welcome to the forums!
So to answer the question in the title, Yes there is a library. I do personally wish Dexter Ind had a complete cheatsheat, but they don’t However the library is fully documented in the LIbrary documentation. If you have Raspbian for Robots or have the library installed on a Raspberry Pi accessing the Documentation is simple. Just type
python into a terminal. (The terminal looks like a tiny black monitor. It should be in the menu bar thing) once that’s done type
import brickpi3 then
help(brickpi3) This will bring up ever single command and what it does, how to use it, etc. To use those commands however you’ll need to type
BP = brickpi3.BrickPi3() and then you can access those commands with
BP.whatever_command You can also call it my_bot or whatever you want instead of BP. But most just use BP. I hope that make sense. I’d advise to read the whole thing (It’s not that long.) That way you’ll have a good understanding of what it can do.
To run a motor a certain amount of time you need use the time python module. Just import it with
import time then run a command to move a motor
BP.set_motor_dps(BP.PORT_A, 150) and put a
time.sleep(number of seconds to run motor) and that will run a motor for a certain number of seconds!
Many thanks for letting me know about this. I had navigated all around the Dexter/BrickPi3 directory but hadn’t thought of this
Now it is all perfectly clear!
and because there must be 20 characters: