Arduino powered hangman giftbox/lockbox using ATmega328 microcontroller

powered hangmanA medium sized box that requires the user to succeed in a game of hang man in order to gain access to the contents of the box.  Great gift Idea!!!
my Arduino sketch will be included in this instructible
sorry for the poor quality pictures!
and keep in mind this is my first instructable,
and I forgot to take pictures of the build in process,
all of these pics are from the completed project.
If you have any questions send me an email and I will get back to you asap, [email protected]
I “borrowed” a lot of code from Dan Wagoner over at, you can find his “hangmamduino” project there as well, and Dan Wagoner if you somehow stumble upon this “ible”, thanks for sharing your code, also I would recommend getting a copy of the “truerandom” library and incorporate that into your code as I did, as the native random function is “psuedorandam”.

Step 1 Parts

I am not supplying instruction for the servo lock construction as the parts I used may not be easy to find, its ok just look at the pics below and you will devise something probably a lot better and cleaner 😉
Parts needed:
1 – wooden box
1 – Arduino board with atmega 328
1 – 16×2 LCD display (get a good price at
2 – 10k potentiometer (if you got your LCD from adafruit it comes with 1 so you only need 1)
1 – knob for potentiometer
2 – normally open momentary contact switch (button)
1 – servo
2 – 10k resistors
1 – speaker
1 – main power switch
1 – LED with built in mount and resistor
2 – plastic project boxes
1 – 9volt battery and battery strap
lots of wire and solder/soldering iron
parts to make the mechanical lock(I used random hardware I had laying around, see pic)
hot glue gun
dremel tool and drill
If you are going to take the atmega328 out of the arduino board to use the board with other projects later you will also need:
1 – piece of printed circuit board (PCB) or perf board
1 – atmega328
1 – 28 pin MCU socket
1 – 16mhz crystal
2 – 22pf capacitors
1 – 5 volt regulator
1 – 10nf capacitor
1 – 22uf capacitor (use radial lead not axial lead, non-polarized will not work)

Step 2 Sketch

Here is the sketch for the Arduino IDE, also included are the “string” and “truerandom” libraries required for this script to work, head over to for instructions on how to install libraries into the IDE.

Step 3 Solder ATmega328 to PCB

Solder ATmega328 to PCBfollow the instructions on the following instructable (this one is explained better than I could possible try)
I will be referring to all pins on the ATmega328 as Arduino pins, I would recommend printing out the atmega328 to arduino pinout map from the above instructable on step 5 picture 2.
also solder a 10k resistor from digital 3 to ground, and another from digital 6 to ground

Step 4 Wiring map for reference

Use this page as reference the wire map is also included in the arduino sketch
analog 0 – DO NOT USE!!!
digital 3 – button inside
analog 3 – 10k pot outside
digital 4 – servo
digital 5 – speaker
digital 6 – button outside
digital 7 – LCD D4 11
digital 8 – LCD D5 12
digital 9 – LCD D6 13
digital 10 – LCD D7 14
digital 11 – LCD RW 5
digital 12 – LCD RS 4
LCD 2 – V+
LCD 3 – Contrast, 10k pot
LCD 15 – V+
LCD 16 – GND
For more Detail: Arduino powered hangman giftbox/lockbox using ATmega328 microcontroller

About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top