Created
May 30, 2018 18:27
-
-
Save omiq/712c7a509f1456b3b28e1df937454155 to your computer and use it in GitHub Desktop.
Motors on CPX with Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from busio import I2C | |
from adafruit_seesaw.seesaw import Seesaw | |
from adafruit_seesaw.pwmout import PWMOut | |
from adafruit_motor import motor | |
import board | |
import time | |
# seesaw object | |
i2c = I2C(board.SCL, board.SDA) | |
seesaw = Seesaw(i2c) | |
# seesaw PWM pins 18, 19, 22 and 23 | |
motor_a = motor.DCMotor(PWMOut(seesaw, 22), PWMOut(seesaw, 23)) | |
motor_b = motor.DCMotor(PWMOut(seesaw, 19), PWMOut(seesaw, 18)) | |
while True: | |
motor_a.throttle = 1 # full speed forward | |
motor_b.throttle = -1 # full speed backward | |
time.sleep(1) | |
motor_a.throttle = 0 # stopped | |
motor_b.throttle = 0 # also stopped | |
time.sleep(0.5) | |
motor_a.throttle = -1 # full speed backward | |
motor_b.throttle = 1 # full speed forward | |
time.sleep(1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment