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!
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
Level 1 Scratch - Make a Flappy Bird Game

Scratch Coding Challenge: Build Flappy Bird In this challenge, you will build your own version of Flappy Bird in Scratch. Flappy Bird was one of the most downloaded mobile games in the early days of touchscreen devices. The idea is simple: This isn't meant to be cookbook coding. Great programmers learn by breaking problems into […]

Read More
Code a Mini Economy Town in Scratch

Development Guide: Code a Mini Economy Town in Scratch This guide explains how to build a dice-powered city simulator in Scratch. You will learn how to manage a virtual economy, use cloning to build a visual city, and create a multi-level progression system. You can check out this project on Scratch. Dicy City Scratch We […]

Read More
Code a Town Economy Game

Code a Mini Economy Town: A Development Guide This guide breaks down the creation of Dice City Tycoon, a browser-based economic simulator. We developed this game in five distinct phases, moving from a simple text-based engine to a polished, multi-level city builder. This page is all about building the game in HTML for a Web Browser. […]

Read More
Create a Downhill Skier Game

DOWNHILL SKIER GAME CODING CHALLENGE The Challenge Your mission is to create a downhill skiing game.The skier stays near the top of the screen while the world moves toward them. Goal:Avoid obstacles for as long as possible. This game uses a classic trick in game design:If the environment moves, it feels like the player is […]

Read More
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
linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram