May 23, 2025

Mastering Precise Turns with LEGO Spike Prime and the Yaw Sensor

Mastering Precise Turns with LEGO Spike Prime and the Yaw Sensor

Objective:
Equip students with the knowledge and skills to utilize the Spike Prime Hub's Yaw sensor for accurate robot turns, leading to improved navigation and higher scores in competitions.

This lesson is available in a video format on YouTube.


Lesson Overview

  1. Understanding the Yaw Sensor
  2. Displaying Yaw Values on the Hub
  3. Programming Precise In-Place Turns
  4. Creating Reusable 'My Blocks' for Turns
  5. Applying Skills in FLL Challenges

1. Understanding the Yaw Sensor

What is Yaw?
Yaw refers to the robot’s rotation around the vertical axis—essentially, its ability to turn left or right in place.

Yaw Angle Range:
The Spike Prime Hub measures yaw angles from -180° to 179°.

  • Positive values = Clockwise turn
  • Negative values = Counterclockwise turn

2. Displaying Yaw Values on the Hub

Goal:
Use a variable to monitor the yaw angle in real time.

Steps:

  • Create a variable called Yaw.
  • Use a loop to continually update this variable.
  • Display the yaw value on the Hub.

Sample Pseudocode for Word Blocks:

When program starts
Set Yaw to 0
Forever
Set Yaw to motion sensor yaw angle
Display Yaw on Hub

3. Programming Precise In-Place Turns

Goal:
Use Yaw data to turn exactly a desired number of degrees.

Steps:

  • Reset yaw angle to 0.
  • Start motors to rotate the robot.
  • Use wait until to stop when the desired yaw angle is reached.

Sample Code (Pseudocode for Word Blocks):

When program starts
Reset yaw angle to 0
Start motors: Left forward, Right backward
Wait until yaw angle is greater than 90
Stop motors

4. Creating Reusable 'My Blocks' for Turns

Goal:
Make your code cleaner and more powerful with a custom block.

Steps:

  • Create a My Block called Turn Degrees with one input: angle.
  • Inside the block:
    • Reset the yaw angle.
    • Decide motor direction based on angle.
    • Rotate the robot.
    • Stop once yaw equals the input angle.

Sample Code (Pseudocode for Word Blocks):

Define 'Turn Degrees' with input 'angle'
Reset yaw angle to 0

If angle > 0
Start motors: Left forward, Right backward
Else
Start motors: Left backward, Right forward

Wait until value of yaw = value of 'angle'
Stop motors

5. Applying Skills in FLL Challenges

Benefits of Precise Turns:

  • ✅ Better field alignment
  • ✅ More reliable missions
  • ✅ Easier to debug and reuse code

Practice Activity:
Have students code the robot to drive in a square using four 90° turns, returning to the starting point.


📥 Resources

Recent Posts

Sprattronics Learning Lab helps families to maximize their education.
February 6, 2026
Sarah E. Goode LEGO Folding Desk to Bed Build

Overview Design a LEGO build that transforms from a desk into a bed, inspired by Sarah E. Goode’s folding cabinet bed. This challenge highlights how engineers solve real problems—like limited living space—by creating furniture that serves multiple purposes. Watch the full build video: https://youtu.be/h9pIRXLIa8w Best for: Grades 2–6Kits: LEGO Spike Prime or Spike EssentialTime: 45–60 […]

Read More
February 4, 2026
Alexander Miles - LEGO Spike Automatic Door Build

Overview Build a LEGO robot that opens and closes a door automatically—no hands required. This challenge is inspired by Alexander Miles, the inventor whose automatic elevator door system made buildings safer and helped shape modern cities. Watch the full build video: https://youtu.be/CT-ELr0o-v0 Best for: Grades 2–6Kits: LEGO Spike Prime or Spike EssentialTime: 45–60 minutes Who […]

Read More
February 2, 2026
Garrett Morgan LEGO Traffic Signal Build

Build a working LEGO traffic signal inspired by Garrett Morgan, the inventor whose improved traffic light design helped make roads safer. In this challenge, students design a motorized signal system, learn why timing and clear communication matter, and connect history to real engineering decisions. Watch the Video! Click Here Who Was Garrett Morgan? Garrett Morgan […]

Read More
© Copyright 2023 - Sprattronics LLC- All Rights Reserved
linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram