January 31, 2026

Build a Caesar Cipher with LEGO SPIKE Prime (Enigma Machine Challenge)

My gumball machine coins disappeared… and in their place was a secret message.

The only way to crack it? Build an Enigma-style cipher machine using LEGO SPIKE Prime.

In this challenge, we design and program a LEGO robot that can encode and decode messages using a Caesar Cipher. One motor selects the cipher key, another selects letters, and the SPIKE hub displays everything as the code comes to life.

Along the way, we:

  • Build a working cipher machine with LEGO SPIKE Prime
  • Use motors as input dials for letters and cipher keys
  • Create an alphabet list (array) to store letters
  • Apply a shift to encode and decode messages
  • Troubleshoot edge cases at the start and end of the alphabet

Once the code is cracked, the mystery is solved… and the gumball machine is back in business 🍬

This project is perfect for:

  • Computer science fundamentals
  • Cryptography for kids
  • FIRST LEGO League teams
  • LEGO robotics classrooms

Want to try this challenge yourself? Grab your SPIKE Prime kit and start decoding!

Here is my code to get you going!

Classroom Challenge: LEGO Enigma Machine

Challenge Story

The coins for the gumball machine are missing! In their place is a secret coded message. Your mission is to design and program a LEGO SPIKE Prime Enigma-style machine that can encode and decode messages using a Caesar Cipher. Crack the code, recover the coins, and save the day.

Learning Goals

  • Understand how a Caesar Cipher works
  • Use lists (arrays) to store and access data
  • Apply shifts to encode and decode letters
  • Use motors and buttons as inputs
  • Debug edge cases at the start and end of the alphabet

Materials

  • LEGO SPIKE Prime Hub
  • 2 Motors
  • Building pieces for dials/buttons
  • Computer or tablet with SPIKE app

Build Requirements

Your Enigma Machine must include:

  • 🔄 Motor 1: Select the cipher key (shift value)
  • 🔤 Motor 2: Select a letter
  • ◀️ Left Button: Decode a letter
  • ▶️ Right Button: Encode a letter
  • 📟 Hub Display: Show the selected letter and result

💻 Programming Tasks

  1. Create a list (array) that holds the alphabet (A–Z)
  2. Program Motor 1 to select a cipher key
  3. Program Motor 2 to select a letter from the list
  4. Encode the letter by shifting forward
  5. Decode the letter by shifting backward
  6. Fix errors when shifting past A or Z

🧠 Think About It

  • What happens if your shift goes past Z?
  • How can you loop back to the start of the alphabet?
  • How would this cipher change if we added symbols or numbers?

🧪 Bonus Challenges (Optional)

⭐ Add sound or light feedback when a letter is encoded

⭐ Decode a full word instead of a single letter

⭐ Hide the message somewhere in the room for another team

⭐ Increase difficulty with a random cipher key


🏁 Success Criteria

✅ Machine encodes and decodes letters correctly

✅ Cipher key can be changed using a motor

✅ Alphabet list is used in the program

✅ Edge cases (A/Z) work correctly


🏆 Mission Complete!

You cracked the code, found the coins, and unlocked the gumball machine. Great work, codebreaker!

Recent Posts

Sprattronics Learning Lab will maximize your education!
Arctic Animal Science: Polar Bears

1. Introduction and Build Meet an Apex Predator Polar bears are the largest land predators on Earth. They live in the Arctic and the Northern Hemisphere, where they spend much of their time on sea ice and in the surrounding coastal areas. Polar bears are apex predators, which means they are at the top of […]

Read More
Arctic Animal Science: Reindeer Adaptations

1. Introduction & Build Welcome to the Arctic Tundra! The Arctic tundra is a challenging place to live. Temperatures can become extremely cold, snow can cover the ground, and finding food can become difficult. Yet reindeer survive here year after year. How do they do it? Reindeer have special adaptations that help them survive in […]

Read More
Arctic Animal Science : Walruses

Welcome to the Arctic Ocean! The Arctic Ocean is the smallest and shallowest of Earth's five oceans. It surrounds the North Pole and is one of the coldest ocean environments on Earth. Much of the Arctic Ocean is covered by sea ice, especially during the coldest parts of the year. Even though the environment is […]

Read More
Arctic Animals: Engineering in a Frozen World

Welcome to the Arctic! The Arctic is the far northern region of Earth. It surrounds the North Pole and includes everything north of the Arctic Circle, an imaginary line located at about 66.5° north latitude. The Arctic is one of the coldest places on Earth. Much of the land is treeless, and the region is […]

Read More
Get the Gold

Get the Gold! LEGO® Education Computer Science & AI Grade 3 - 5 Unit 1 • Lesson 1 Student Sheet Mission A treasure of gold is waiting! Your job is to build a horse and carriage, then write a program that helps your robot travel from the castle to the gold and safely back home […]

Read More
LEGO Education Computer Science & AI Kit: The Ultimate Getting Started Guide

LEGO Education Computer Science & AI Kit: The Ultimate Getting Started Guide You Placed Your Order and the Kit is on the Way... Now What? Congratulations! You've ordered the LEGO Education Computer Science & AI Set. Whether you're a classroom teacher, homeschool parent, after-school educator, or robotics enthusiast, you're about to unlock dozens of engaging […]

Read More
linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram