В момента ресурсът е наличен само на английски

Python program to move in straight line with the gyro sensor from LEGO Education SPIKE Prime

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()

How to open?

Download
  • #wpzvn4
  • 15 Mar 2021

Курсове и занятия включващи този Програма

Този Програма е използван в следните курсове и занятия.

Image for FIRST LEGO League with LEGO Education SPIKE Prime. "Challenge" competition for 9-16 years old
  • 40
  • 127:22
  • 24
Image for Move straight with the Motion Sensor
  • 1
  • 0
  • 1
  • 3d_rotation 1