Created
November 3, 2017 13:24
-
-
Save jan-martinek/2b240b1527e4ace438a70cc621652e15 to your computer and use it in GitHub Desktop.
Simple turtle graphics script for use with STS-Pi and explorerhat (no pen logic)
This file contains hidden or 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
#!/usr/bin/env python | |
# Explorer HAT/pHAT https://shop.pimoroni.com/search?type=product&q=explorer+hat | |
# STS-Pi https://shop.pimoroni.com/products/sts-pi | |
import time | |
import explorerhat | |
speed = 100 | |
turnCoef = 0.57 | |
def forward(dist): | |
motorL(speed) | |
motorR(speed) | |
time.sleep(dist) | |
def back(dist): | |
motorL(-speed) | |
motorR(-speed) | |
time.sleep(dist) | |
def right(deg): | |
motorL(speed) | |
motorR(-speed) | |
time.sleep(deg / 90 * turnCoef) | |
def left(deg): | |
motorL(-speed) | |
motorR(speed) | |
time.sleep(deg / 90 * turnCoef) | |
def motorL(speed): | |
explorerhat.motor.one.speed(speed) | |
def motorR(speed): | |
explorerhat.motor.two.speed(speed) | |
while True: | |
forward(2); | |
right(90); | |
explorerhat.pause() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment