top of page

Physical Computing Week 3: I/O Assignment

For this assignment I wanted to make a tilt maze game run with servo motors and potentiometers. I largely picked this assignment because I've never made a physical device that uses motors, along my own code to control it. I also knew that the programming side would be fairly straightforward, leaving me more time to play with the design and build itself.


Originally, I wanted to make a complex, multi-story maze, something that might require a bit more skill or more time to figure out. I was inspired by the marble runs in the most recent Resident Evil Games and I haven't seen anything quite like this done before:

Obviously a design like this would be too complex for a short build, but I was inspired nevertheless. I was also thinking a lot about old games I used to play growing up like Sonic the Hedgehog or Marble Madness and thought a maze inspired by those games would be a lot of fun.

A section of the Green Hill Zone in Sonic the Hedgehog. How cool would this be as a 3D maze game??

Various maps in the original marble madness arcade game

The 5th level in Crystal Castles

While these are all terrible ambitious, this is sort of where my idea started to build this game. I realized that I didn't have enough time to sit down and really design a maze and so I started thinking about iconic mazes from games/film/popular culture that I could pull from. I landed on...

The Overlook Hotel hedge maze from The Shining! I do adore this film and I couldn't find another example project using this specific maze - so I thought it would be perfect for this project. Not too long ago I watched Adam Savage of Tested build a replica of the maze model seen in the image above, which is where I learned that there are actually multiple versions of the maze featured in the film. The design I was most interested in was the design from the areal shot of the film:

However, I quickly realized that my physical maze would have to be VERY large in order to fit a ball bearing into it - a project for another time perhaps.

So I settled on the maze as seen in the Overlook Hotel maze map which you can see in this clip:

Once I settled on the maze design, I took to SolidWorks to begin creating the table. I had to make several adjustments to the overall design itself so I could print it within the due date of the project, which means it's not quite as close to the proportions of the actual hedge maze featured in the film. I picked 3D printing/PLA as a medium/material because I thought it would lend itself well to having more control over the mechanics of this build - and I have a TON of old filament that I need to use. PLA is a very rigid plastic

(which is necessary for this project), and it's also easy to print with.

This is the original design of the marble maze game. I went with a fully enclosed design as a way to hide the electronics, but at the same time it uses up way more plastic and take a lot more time to build, so I may end up redesigning this in the future with a better design that consumes less plastic.

Here's the inside of the container. There's a compartment to house the electronics as well as a ramp which will roll the ball through a hole in the front of the case, signaling that you won the game (and get to keep the ball I guess)?

Printing and assembling this thing was difficult. I had to cut some corners for time and it's a lot more delicate than I would have liked which ultimately affected the amount of control you have while playing it. I also screwed up with the design of the potentiometer slot, so I had to manually drill out the hole for that on one side of the case. That and a few other hiccups made this build a bit frustrating.

Printing the large maze section (12 inches in length)

The wiring and programming were quite easy, although it took a bit of time to nail the mapping of the potentiometer to the servo motors themselves. I'm sure there is a better way in code to control them, but my programming skills are not there yet.


Here's the code:

#include "Servo.h"      // include the servo library

Servo yMotor;// creates an instance of the servo object to control a servo
Servo xMotor;
int servoPin1 = 2;  // Control pin for servo motor
int servoPin2 = 3;
int yMotorHomePos = 80;
int xMotorHomePos = 80;
void setup() {
  //Serial.begin(9600);       // initialize serial communications
  yMotor.attach(servoPin1);// attaches the servo on pin 2 to the servo object
  xMotor.attach(servoPin2); //attaches the servo on pin 2 to the servo object
  yMotor.write(yMotorHomePos); //update motor with home position at startup
  xMotor.write(xMotorHomePos); //update motor with home position at startup
void loop()
  int leftPot = analogRead(A0);
  int rightPot = analogRead(A1);// read the analog input

//--------------------  Serial.println(leftPot);

  // print it

//map the analog input value to the angle of the servo:
  int yTilt = map(leftPot, 1023, 0, 70, 100);
  int xTilt = map(rightPot, 0, 1023, 65, 95);

  // move the servo using the angle from the sensor:

The wiring diagram - still trying to figure out how to draw these to be honest

I had trouble with some excessive jerky movements on the x-axis rotation, which is odd because in my initial testing that didn't happen at all. I tried switching power supplies to no avail. I came to the conclusion that it's likely an issue with the design and fabrication of the table itself as it's quite wobbly due to printing the frame thin and hollow. But it's possible that it might have something to do with the power supply. Here's a video of me playing with it!

The "ball out" currently doesn't work very well, I didn't make the walls tall enough and the slope is a bit too shallow to work properly with the current resolution of the base. I also didn't include enough of a cavity for the cabling to slip though, so I definitely will need to iterate on the design a bit - but as a first prototype I think it's working quite well.


bottom of page