Skip to content

Instantly share code, notes, and snippets.

@xeecos
Created May 28, 2021 03:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xeecos/5fa6cb5876a8c9449562d8026942fff1 to your computer and use it in GitHub Desktop.
Save xeecos/5fa6cb5876a8c9449562d8026942fff1 to your computer and use it in GitHub Desktop.
###USAGE###
# pip3 install makeblock
###########
from time import sleep
from makeblock import MegaPi,SerialPort
megapi = MegaPi.connect() # or megapi = MegaPi.connect(SerialPort.connect("/dev/ttyXXXX"))
motor1 = megapi.DCMotor(1,1)
motor2 = megapi.DCMotor(1,2)
motor3 = megapi.DCMotor(2,1)
motor4 = megapi.DCMotor(2,2)
motor1.run(50)
motor2.run(50)
motor3.run(50)
motor4.run(50)
sleep(1)
motor1.run(0)
motor2.run(0)
motor3.run(0)
motor4.run(0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment