Programs -
Filters:
Python program to accomplish FLL 2020 Step Counter, with LEGO Education SPIKE Prime
This Python program is for controlling Gazon, LEGO Education SPIKE Prime competition robot to accomplish FIRST LEGO League (FLL) 2020 RePLAY Challenge mission 02 - Step counter. Check out the lessons where this program is use for specific demonstrations and explanations on how the program works.
- #56nfji
- 07 Jul 2021
Python program to accomplish FLL 2020 RePLAY Weight Machine, with LEGO Education SPIKE Prime
This Python program is for controlling Gazon, LEGO Education SPIKE Prime competition robot to accomplish FIRST LEGO League (FLL) 2020 RePLAY Challenge mission 13 - Weight Machine using Attachment for FLL 2020 RePLAY Weight Machine mission
.- #y68kz1
- 06 Jul 2021
Python program to accomplish FLL 2020 Pull-Up bar, with LEGO Education SPIKE Prime
This Python program is for controlling Gazon, LEGO Education SPIKE Prime competition robot to accomplish FIRST LEGO League (FLL) 2020 RePLAY Challenge mission 06 - Pull-Up Bar using Attachment for FLL 2020 Pull-Up bar mission
.- #zcmnfb
- 03 Jul 2021
Python program to accomplish FLL 2020 RePLAY Rowing Machine, with LEGO Education SPIKE Prime
This Python program is for controlling Gazon, LEGO Education SPIKE Prime competition robot to accomplish FIRST LEGO League (FLL) 2020 RePLAY Challenge mission 12 - Row Machine using Attachment for FLL 2020 RePLAY Rowing Machine mission
.- #8cdu7o
- 30 Jun 2021
Python program to accomplish FLL 2020 Tire Flip, with LEGO Education SPIKE Prime
This Python program is for controlling Gazon, LEGO Education SPIKE Prime competition robot to accomplish FIRST LEGO League (FLL) 2020 RePLAY Challenge mission 09 - Tire Flip using Attachment for FLL 2020 Tire Flip mission
.- #y0zbsj
- 27 Jun 2021
Python program for drop attachment from LEGO Education SPIKE Prime
Developed with LEGO Education SPIKE App Python this program is used to accomplish the Drop mission model with a Drop attachment placed on Luly, small LEGO Education SPIKE Prime competition robot with 3D building instructions.
- #ozqrcd
- 17 Mar 2021
Python program for push/pull attachment from LEGO Education SPIKE Prime
LEGO Education SPIKE App Python program used to accomplish the many missions with a Push/Pull placed on Luly, small LEGO Education SPIKE Prime competition robot with 3D building instructions.
- #zyg87r
- 17 Mar 2021
Python program for throw attachment from LEGO Education SPIKE Prime
LEGO Education SPIKE App Python program used to accomplish the Bowling mission with a Throw attachments placed on Luly, small LEGO Education SPIKE Prime competition robot with 3D building instructions.
- #oymise
- 17 Mar 2021
Python program for a front/side/top attachment form LEGO Education SPIKE Prime, accomplishing Power Switch mission
Developed with LEGO Education SPIKE App Python this program is used to accomplish the Power Switch mission model with a Front attachment placed on Luly, small LEGO Education SPIKE Prime competition robot with 3D building instructions.
- #tmyc6g
- 17 Mar 2021
Python program to align to a line with color sensors from LEGO Education SPIKE Prime
This program is developed with LEGO Education SPIKE App Python and is used to make the Luly, small LEGO Education SPIKE Prime competition robot with 3D building instructions align to a line with two color sensor. It's a mechanism we've used with EV3, NXT and now SPIKE.
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() color_sensor_E = ColorSensor('E') color_sensor_F = ColorSensor('F') motor_A = Motor('A') # Set the motor port to the motor. motor_B = Motor('B') # Set the motor port to the motor. motor_A.set_default_speed(-30) # Set the default speed of the motor. motor_B.set_default_speed(30) # Set the default speed of the motor. motor_A.set_stop_action('brake') # Activate the brakes when the motor stops. The other conditions are 'hold' and 'coast'. motor_B.set_stop_action('brake') # Activate the brakes when the motor stops. motor_A_flag = 0 # Create a flag for motor A and set it to OFF. motor_B_flag = 0 # Create a flag for motor B and set it to OFF. def stop_at(colour): motor_A_flag = 0 # Reset the flag for motor A to OFF. motor_B_flag = 0 # Reset the flag for motor B to OFF. # Move forward. motor_A.start() motor_B.start() while (motor_A_flag == 0) or (motor_B_flag == 0): # Repeat while both sensors ever detect black color. if color_sensor_E.get_color() == colour: # If the color sensor on port E detect the desired color motor_A.stop() # stop the motor an port A and motor_A_flag = 1 # set the flag for motor A to ON. if color_sensor_F.get_color() == colour: # If the color sensor on port F detect the desired color motor_B.stop() # stop the motor an port B and motor_B_flag = 1 # set the flag for motor B to ON. stop_at('black') stop_at('white') raise SystemExit # Close the program.
- #p2ghxe
- 17 Mar 2021
Python program for an active attachment form LEGO Education SPIKE Prime, accomplishing Power Switch mission
This program is developed with LEGO Education SPIKE App Python and is used to accomplish the Power Switch mission model with Luly, small LEGO Education SPIKE Prime competition robot with 3D building instructions.
- #f9dgvi
- 17 Mar 2021
Python program for a reusable attachment form LEGO Education SPIKE Prime, accomplishing Power Switch mission
This program is developed with LEGO Education SPIKE App Python and is used to accomplish the Power Switch mission model with a reusable geared attachment placed on Luly, small LEGO Education SPIKE Prime competition robot with 3D building instructions.
- #vya8id
- 17 Mar 2021
Python program for heavy lifting attachment from LEGO Education SPIKE Prime
This program is developed with LEGO Education SPIKE App Python and is used to accomplish a Power Switch mission model with a heavy lifting attachment attachment placed on Luly, small LEGO Education SPIKE Prime competition robot with 3D building instructions.
- #qp8s6h
- 17 Mar 2021
Python program for vertical heavy lifting attachment from LEGO Education SPIKE Prime
Developed with LEGO Education SPIKE App Python this program is used to accomplish a Power Switch mission model with a vertical heavy lifting attachment placed on Luly, small LEGO Education SPIKE Prime competition robot with 3D building instructions.
- #5w4ilo
- 17 Mar 2021
Python program for flip attachment from LEGO Education SPIKE Prime
Developed with LEGO Education SPIKE App Python this program is used to accomplish the Flip mission model with a Flip attachment placed on Luly, small LEGO Education SPIKE Prime competition robot with 3D building instructions.
- #9cizqy
- 17 Mar 2021
Python program to stop at distance from the border, with LEGO Education SPIKE Prime
This program is developed with LEGO Education SPIKE App Python and is used to make the Luly, small LEGO Education SPIKE Prime competition robot with 3D building instructions stop at a distance from the border field.
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() distance_sensor = DistanceSensor('C') motor_pair = MotorPair('A', 'B') # Set the motor ports in the motor_pair. motor_pair.set_default_speed(50) # Set the default speed of the motor_pair. motor_pair.set_motor_rotation(17.6, 'cm') # Set the distance that the robot travels for one rotation of its wheels. The value 17.6 comes from # the diameter of the wheel (5.6cm) multiplied by "π" (3.14). motor_pair.set_stop_action('brake') # Activate the brakes when the robot stops. The other conditions are 'hold' and 'coast'. distance_sensor.light_up_all() # Turn on the distance sensor lights. motor_pair.start() # Move forward. distance_sensor.wait_for_distance_closer_than(20, 'cm') # Wait until distance is closer than 20 centimeters. motor_pair.stop() # Stop moving. distance_sensor.light_up_all(0) # Turn off the distance sensor lights. raise SystemExit # Close the program.
- #140q68
- 15 Mar 2021
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()
- #wpzvn4
- 15 Mar 2021
Python program to turn until reaching an angle with LEGO Education SPIKE Prime Gyro Sensor
Python program to turn until reaching an angle with LEGO Education SPIKE Prime Gyro Sensor.
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() motor_pair = MotorPair('A', 'B') # Set the motor ports in the motor_pair. motor_pair.set_default_speed(30) # Set the default speed of the motor_pair. motor_pair.set_motor_rotation(17.6, 'cm') # Set the distance that the robot travels for one rotation of its wheels. The value 17.6 comes from # the diameter of the wheel (5.6cm) multiplied by "π" (3.14). motor_pair.set_stop_action('brake') # Activate the brakes when the robot stops. The other conditions are 'hold' and 'coast'. 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. motor_pair.start(steering = 100) # Turn left around the center of the wheelbase. Leftward because of steering=-100 parameter. # To program the robot to wait until the robot has turned, we need to define a fuction that checks if the robot has turned. def left_turn_end(): # Define the function return hub.motion_sensor.get_yaw_angle() > 90 # Return true or false depending on the yaw angle value. wait_until(left_turn_end) # Wait until the left turn end. left_turn_end is a function that defines the left turn motor_pair.stop() # Stop moving. Hit the brakes! Remember the motor_pair.set_stop_action('brake') statement/setting? raise SystemExit # Close the program.
- #18zxih
- 13 Mar 2021
Python program to move forward, turn left, move forwad, turn right with LEGO Education SPIKE Prime
This program makes the robot move forwards, turn left, move forwards, and then turn right using LEGO Education SPIKE App Python.
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() motor_pair = MotorPair('A', 'B') # Set the motor ports in the motor_pair. motor_pair.set_default_speed(50) # Set the default speed of the motor_pair. motor_pair.set_motor_rotation(17.6, 'cm') # Set the distance that the robot travels for one rotation of its wheels. The value 17.6 comes from # the diameter of the wheel (5.6cm) multiplied by "π" (3.14). motor_pair.move(50,'cm', 0, 50) # Start moving for 50cm with NO Steering '0' at 50% of the maximum speed. motor_pair.move(8.8,'cm', -100, 50) # Start moving for 8.8cm with steering '-100' at 50% of the maximum speed. This makes the robot turn left 90deg # at 50% of the maximum speed of the motors. The value 8.8 represents the angle of rotation. This is the distance every # wheel needs to travel to rotate the robot 90deg. This value is calculated in the following way: The wheel base # (the distance between the points where the wheels touch the ground) is the # diameter of the turn (in this case it is 11,2cm). Since we want to turn 90deg (1/4 of the turn) we multiply # the diameter (11,2) by "π" (3.14) and divide it to 4 as 90 degrees are 1/4 of the circle. motor_pair.move(40,'cm', 0, 50) # Start moving for 50cm with NO Steering '0' at 50% of the maximum speed. motor_pair.move(8.8,'cm', 100, 50) # Start moving for 8.8cm with steering '100' at -50% of the maximum speed. This makes the robot turn right 90deg # at 50% of the maximum speed of the motors. Turn right because the steering is positive 100%. raise SystemExit # Close the program.
- #2xvw1d
- 12 Mar 2021