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!
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
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
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
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 […]

Read More
Mission to Mars LEGO Robotics Unit

Building a Mars Rover with LEGO Robotics A rover is an automated motor vehicle that propels itself across the surface of a celestial body. A rover may examine territory and interesting features, analyze weather conditions, or even test materials, such as soil and water. What does it take to go to Mars? People have long […]

Read More
Robot Rabbits vs. Pythons LEGO Spike Engineering

Download this as a PDF to use in class or at home! Today you are an engineer! Your mission is to design and build a robot rabbit that can move in a rabbit-like way. We’ll use the Engineering Design Process: Challenge → Brainstorm → Design → Create → Test → Improve → Share Real-World Context: […]

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