Last active
February 25, 2022 00:49
-
-
Save marclennox/fc4cc4b95562713b06b6e41451380f38 to your computer and use it in GitHub Desktop.
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 mindstorms import MSHub, Motor, MotorPair, ColorSensor, DistanceSensor, App | |
from mindstorms.control import wait_for_seconds, wait_until, Timer | |
from mindstorms.operator import greater_than, greater_than_or_equal_to, less_than, less_than_or_equal_to, equal_to, not_equal_to | |
import math | |
# Create your objects here. | |
tricky = MSHub() | |
movement_motors = MotorPair('A','B') | |
distance_sensor = DistanceSensor('D') | |
lifting_arm = Motor('C') | |
# Write your program here. | |
tricky.speaker.beep() | |
lifting_arm.run_to_position(5,'shortest path',10) | |
# Set the default speed and start moving until we sense the ball is close (7cm) | |
# You can replace 'shortest path' with 'clockwise' or 'counterclockwise' | |
movement_motors.set_default_speed(30) | |
movement_motors.start() | |
distance_sensor.wait_for_distance_closer_than(7,'cm') | |
# Stop moving and lift the ball into the air | |
movement_motors.stop() | |
lifting_arm.run_to_position(270,'shortest path',10) | |
# Spin tricky around fast and then slower | |
movement_motors.move(20,'cm',60) | |
movement_motors.move_tank(20,'cm',50,30) | |
#move motors by rotation: | |
"""lifting_arm.run_for_rotations(1,50) | |
""" | |
#move motor by seconds: | |
""" | |
lifting_arm.run_for_seconds(3,-100) | |
""" | |
#move motors by degrees: | |
""" | |
lifting_arm.run_for_degrees(90,80) | |
""" | |
#set motor default speed: | |
""" | |
lifting_arm.set_default_speed(50) | |
""" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment