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!
Control a LEGO Spike Robot with Motion: Using the Gyroscope

Control LEGO Spike Essential with Motion: Using a Gyroscope Introduce Today we are going to learn how to control a robot in a completely different way. Instead of pressing buttons or using a controller, we will use motion. The LEGO SPIKE hub has a built-in gyroscope that can detect how it is tilted, and we […]

Read More
Digestion Dash: The Ultimate Body Adventure!

Digestion Dash: The Ultimate Body Adventure! Get ready to race through the human body in Digestion Dash! In this game, you’ll follow food on an epic journey—from the first bite all the way to the end. Along the way, you’ll play mini-games and learn how your digestive system turns food into nutrients your body can […]

Read More
Build a LEGO Elevator!

Architecture Week Challenge: Build a LEGO Elevator! Can you design and build a working elevator using LEGO Robotics? This week at Sprattronics Learning Lab, your mission is to take your minifigures from low to high—just like real engineers do in skyscrapers around the world! Watch the Challenge Video First Before you start building, watch this […]

Read More
Can You Design a Video Game About Animal Senses?

Can You Design a Video Game About Animal Senses? Your Challenge Create a video game where the main character survives using its senses. You’ll need to: Your mission is to design a game that shows how animals sense, process information, and respond in order to survive. Why Animal Senses Make Great Video Games Animals experience […]

Read More
Interactive Weather Game

Interactive Weather Game: Learn the Water Cycle by Controlling a Cloud If you’re looking for a hands-on way to teach the water cycle and basic weather science, this browser-based game offers an engaging, intuitive experience. Players control a cloud, collect water vapor, release rain, and watch plants grow as they explore how water moves through […]

Read More
LEGO Baseplate Builder

Free 16x16 LEGO® Plate Builder: Create Custom LEGO Challenge Cards Unlock your creativity and kickstart your next building session with the Sprattronics LEGO Plate Builder. This free digital tool is designed specifically for educators, parents, and LEGO fans to design 16x16 LEGO Challenge Cards in seconds. Whether you are looking for a quick STEM warmup or a way […]

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