Introduction: Let's Build a Japanese Crane Game With LEGO SPIKE Prime and C!
Crane games are super fun and popular in Japan—you’ll find them in arcades everywhere!
This time, we decided to recreate a mini version of the Japanese crane game using LEGO SPIKE Prime and C programming.
Can you grab the candy perfectly? Let’s try!
Supplies
- 1 PC with Windows 10 or 11 operating system.
- SPIKE Prime
Step 1: Robot Setup
Here’s what we used to build our crane game robot:
- Crane movement: 3 motors control forward, backward, left/right, and the gripper
- Control buttons: Force sensor (to move the crane)
- Coin system (optional): Color sensor to detect inserted “coins”
- Prize detection (optional): Distance sensor to check if you grabbed the candy!
Step 2: Features
Crane Arm
The crane moves in all directions—left, right, forward, and backward—and it grabs things with a claw.
We used three motors to control all the parts. The gripper opens and closes to catch the candy.
Control Button
Want to move the crane? Just press the force sensor!
- On the first press-and-hold, the crane moves sideways (left or right).
- On the second press-and-hold, the crane moves backward.
- After both movements, the gripper automatically lowers and tries to grab the candy.
The crane only moves while you’re holding the button down—just like a real crane game in an arcade!
Step 3: Add More Fun!
Want to make your crane game even more awesome? Try these upgrades:
Coin Detection (Color Sensor)
Use a color sensor to detect a coin-shaped block.
Only play if a “coin” is inserted! You can even program different coin colors to give different playtimes.
Candy Detection (Distance Sensor)
Add a distance sensor to detect if the candy falls into the prize chute.
If it does, you win! The robot can even play music to celebrate your success!
Step 4: Let’s Play!
We had a blast building this Japanese-style crane game using LEGO SPIKE Prime and C.
It’s a fun project for kids, students, or anyone who loves arcade games and robotics.
Ready to try it yourself? What kind of prizes would you put inside?
Step 5: 【Free Trial】Start C Language Programming With Afrel's Educational Materials
Are you intrigued by the idea of programming your SPIKE™ Prime with C? Did you know that Afrel is a key information provider for SPIKE™ Prime?
To meet the demand of those who want to "learn more about SPIKE™ Prime " and "try programming in C," Afrel has developed and sells educational materials for learning C language programming with SPIKE™ Prime.
Stepping up from Python to C is an excellent opportunity to further enhance your programming skills. Learning C will give you a deeper understanding of how computers work and enable more advanced control.
Afrel's C language materials are designed for beginners, ensuring a smooth learning experience. Why not take this chance to discover the joy of controlling SPIKE™ Prime with C and expand your programming horizons?
If you're ready to tackle C language programming, click the link below for more details.
Learn more about SPIKE™ Prime C Language Programming Materials here





