Servo Controlled Labyrinth




Do you know this classic wooden labyrinth game with two knobs for X and Y rotation?

So, I've decided to modify one by connecting two standard servos to the knobs and let a microcontroller (ATmega32) play the game.

- To CarlS for inspiration.
- To the AVR freaks especially Dean (aka abcminiuser) for his excellent tutorials.

Please, feel free to write ideas for improvements and modifications.

Step 1: Materials, Parts and Tools

I found all the materials for this project laying around at home and there were no plans nor designing. I just took the materials and thought how I can assemble them altogether.
You can use other materials and basically it's a good practice to design and make plans beforehand.

1 wooden Labyrinth - 280/230/60 mm
1 wooden board - 400/350/20 mm
4 pieces of wood – 30/30/10 mm
2 pieces of wood - 150/155/10 mm each
2 pieces of wood, L shaped – 120/27/4 mm each side
4 pieces of wood, L shaped – 34/32/8 mm & 18/32/8 mm each
600 mm long strong silk string
8 pieces of rubber – 30/30/1 mm each
4 L brackets, stainless steel – 32/32/1.5 mm each
8 bolts (40/5 mm) with nuts and washers
A bunch of small wood screws and nails
a piece of paper, A4 for example
contact adhesive
insulating tape

2 Hitec HS-311 Standard servos
AVR ATmega32 and a programmer – I use the AVR-LIP (EC-AVR) by DeccanRobots
2 straight switch knobs
1 breadboard
Some wires and pins

saw, screw-driver, hammer, sharp knife, scissors, clamp etc.

Step 2: Labyrinth Modifications

Cut the servo horns (#13 R-D) just to make it symmetrical and use a hot glue to connect it to the switch knobs (90 deg. to the knob's pointer).
Replace the two wooden side knobs with these switch knobs in order to calibrate the labyrinth easily.

To improve the strings/bars friction, replace the two nylon strings with a strong silk string and put some contact adhesive around the steel bars.

Put insulating tape on the inner side of each labyrinth's hole and round pieces of paper on the outer side so the ball will stay on the board as long as you test the game.

Step 3: Servo Modules

Each servo sits in its own holder and each such servo module connects to the main board with bolts, nuts and washers. This way it's easy to adjust the servo to the labyrinth knobs.
Just follow the attached photos and you'll understand how to assemble it all.

Now, few things:
- Don't drill holes for the servos before you know the proper height acording to the knobs.
- You will have to make room for the servo's cable, do it carefully.
- Drill the holes on the main board much wider than the bolts of the servo modules.

Finally,  Add the two long wooden "L" to the main borad.

Step 4: The Controller

A standard servo operates at 50Hz which means it needs to get a pulse at its control line (Hitec - the yellow one) every 20ms.
The width of the pulse in its active state (duty cycle) determines the angle of the servo.
This modulation of the pulse width known as PWM - Pulse-Width Modulation.
1.25 ms - 0 deg.
1.50 ms - 90 deg.
1.75 ms - 180 deg.

The Code
The best method - correct me if I'm wrong - to create PWM with ATmega for two servos is by connecting the 1st servo to OC1A and the 2nd one to OC1B and program each of these timers to output PWM.
Now, the development board I have and use is AVR-LIP (ECAVR) and OC1A and OC1B are already taken by the LCD and by the piezo buzzer.
So - with the help of [frakk2136] -  I used different method.
I programmed OC1A to produce fast PWM and used interrupts while the servos are connected to PA4 & PA5.
You'll have to modify the code according to your system.

Some Comments
Three versions here:
The game automatically played according to a set of instructions.
The code works great, but the labyrinth mechanism just cannot be calibrated well enough.
Now, add some physical factors like gravity, friction, tension (especially this X-factor) etc. and, well, sometimes the ball fall into this hole and sometimes to that one.

The microcontroller gets instructions from the PC keyboard (arrow keys) through the serial port.
The AVR-LIP works at 4Mhz so the maximum baud-rate that it can handle with no errors is 19200 which is too slow and not so comfortable.

Four switches are connected to the AVR.
Works great.

[ X ] Analog Joystick
[ X ] Digital Joystick
[ X ] Accelerometer
[ V ] Switches
[ X ] Computer Vision

* ([ X ] | [ V ] = Status)



    • Beauty Tips Contest

      Beauty Tips Contest
    • Pets Challenge

      Pets Challenge
    • Classroom Science Contest

      Classroom Science Contest

    16 Discussions


    6 years ago on Step 4

    This is awesome! I used to own one of these when I was much younger. Now I can win every time haha.


    8 years ago on Introduction

    I've seen something similar a few years ago where the labyrinth was controlled via a Wii fit board. A very cool project indeed.

    Would it be much harder to do something similar with a foosball table? I've seen a basic one made entirely out of wooden dowel rods and thin, flat wood pieces for the players. It would be interesting to build a scaled down model with only a couple of rods for each team, then set up two microcontrollers to battle it out. Likely a LOT more complicated than it sounds but it would be a great project.


    8 years ago on Step 4

    or, if you had an NXT set, jailbreak a friends iPod and use LegoDrive :P to control the NXT directly...


    8 years ago on Introduction

    Nice project, I'm trying to do the same thing.Just have a question or a comment realy.You didnt have any problems keepn this calibrated?


    8 years ago on Introduction

    Hi, Can you please tell me what kind of servo fittings did you use to interface the servos with the switch knobs. Thanks in advance for your help :D

    1 reply

    9 years ago on Introduction

     If you transferred the idea across to Etch-a-sketch, ensuring that the servos were fast enough and if you had some very good programming and electronics knowledge, you could maybe make an Etch-a-sketch CNC monitor that refreshes every four seconds or so. It would look great (even if practicality would be low).

    I too just got one at a second hand store. I think this was very well done but destroys the modern-day purpose of a fun game using no electricity or batteries or motors. Just wood metal and springs.


    9 years ago on Step 4

    Great job. Have you thought about making it controllable from an iPhone/iPod Touch using the accelerometer?

    2 replies

    Reply 9 years ago on Introduction

    I've got no iPhone/iPod, but I'm gonna check any kind of controller with this game. thanks :)


    Reply 9 years ago on Introduction

     Very good project, now add a wii nunchuck! (ebay, very cheap ones there)

    Doctor What

    9 years ago on Introduction

     I've never actually seen one of those ball labyrinths before.  Very fun looking.