from spike import PrimeHub, LightMatrix, Button, StatusLight, ForceSensor, MotionSensor, Speaker, ColorSensor, App, DistanceSensor, Motor, MotorPair
from spike.control import wait_for_seconds, wait_until, Timer
from math import *
hub = PrimeHub()
motorA = Motor('A')
motorB = Motor('B')
motorA.set_default_speed(-30)
motorB.set_default_speed(30)
wait_for_seconds(1) # Wait for one second.
hub.motion_sensor.reset_yaw_angle() # Reset the Gyro sensor. The current yaw angle value is equal to 0.
while True: # Repeat forever.
if hub.motion_sensor.get_yaw_angle() < 0:
motorA.start()
motorB.stop()
else:
motorB.start()
motorA.stop()