loading
 A 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, NOI7734@gmail.com

Note:
I "borrowed" a lot of code from Dan Wagoner over at www.nerdybynature.com, 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 - 16x2 LCD display (get a good price at adafruit.com)
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)


 
Sembot10 days ago

Thanks for you replay

oke i will try, I'll let you know if its works

Sembot18 days ago

Hai

I have the same problem, who can help, I use Arduino Uno a have a error

secretWord = guessWord.getChars();

Have also Arduino Mega or Mega 2560 tried

Kind Regards

cghove Sembot11 days ago

change parts of the code into this:

const char letterVal[] = "_abcdefghijklmnopqrstuvwxyz";

char guessLetter;

char guessLast;

char guessed[25];

const char* secretWord;

int guessedCount = 1;

int wordSize;

int gotOne = 0;

int alreadyGuessed = 0;

int showAsterisk = 0;

int buttonState;

int hangman = 0;

int totalRight = 0;

long lastDebounceTime = 0;

Servo lock; //create a servo object called lock

int button2on; //integer for button inside box

LiquidCrystal lcd(12, 11, 2, 7, 8, 9, 10);

String guessWord = String(42);

// hangman graphic characters

byte topleft[] = { 0x1F, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10 };

byte topright[] = { 0x1C, 0x04, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00 };

byte bottomleft[] = { 0x10, 0x10, 0x10, 0x10, 0x10, 0x1F, 0x1F, 0x1F };

byte bottomright[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };

byte head[] = { 0x1C, 0x04, 0x04, 0x0E, 0x0E, 0x00, 0x00, 0x00 };

byte topbody[] = { 0x1C, 0x04, 0x04, 0x0E, 0x0E, 0x04, 0x04, 0x04 };

byte bottombody[] = { 0x04, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };

byte rightarm[] = { 0x1C, 0x04, 0x04, 0x0E, 0x0E, 0x05, 0x06, 0x04 };

byte leftarm[] = { 0x1C, 0x04, 0x04, 0x0E, 0x0E, 0x15, 0x0E, 0x04 };

byte rightleg[] = { 0x04, 0x04, 0x02, 0x02, 0x01, 0x00, 0x00, 0x00 };

byte leftleg[] = { 0x04, 0x04, 0x0A, 0x0A, 0x11, 0x00, 0x00, 0x00 };

byte leftarrow[] = { 0x10, 0x18, 0x1C, 0x1E, 0x1E, 0x1C, 0x18, 0x10 };

byte rightarrow[] = { 0x01, 0x03, 0x07, 0x0F, 0x0F, 0x07, 0x03, 0x01 };

void setup()

{

lock.write(160); //set lock servo to locked position before it is attatched to prevent servo from moving to 90 degrees on startup

lock.attach(4); // Connected to servo to control lock

Serial.begin(9600);

pinMode (POTPIN, INPUT);

pinMode (BUTTONPIN, INPUT);

pinMode (SPEAKERPIN, OUTPUT);

// pinMode (servon, OUTPUT);

pinMode (button2, INPUT);

lcd.begin(16, 2);

lcd.clear();

lcd.setCursor(1,0);

lcd.print("CACHE");

lcd.setCursor(1,1);

lcd.print("NAVN");

delay(5000);

// pick a random word using analog 5 for random data

//randomSeed(analogRead(4));

newWord();

//draw the board

draw_board();

// digitalWrite(servon, HIGH);

lock.write(160);

delay(1000);

// digitalWrite(servon, LOW);

}

void newWord(){

//pick a random word from the list

int pick = TrueRandom.random(NUMWORDS);

const char* pickWord = words[pick];

guessWord = pickWord;

secretWord = guessWord.c_str();

wordSize = guessWord.length();

Serial.println(guessWord); // print the word to serial for cheaters like me ;) ...or for testing purposes.

}

cghove19 days ago

hmm.... can't get it to work, could it be that it wont work with arduino uno?

cghove19 days ago

The servo keeps living its own life, and when i connect a button to digital 6, the game automaticly Wins......

danwagoner5 years ago
It's always nice to see someone "borrow" code. Thanks for the credit...and the random library tip. When I was writing the code I never guessed someone would use it for a lock. Hopefully you also included more words in the dictionary. :)
NOI7734 (author)  danwagoner5 years ago
yes I found a list of the 42 hardest words for hangman, so I used those words, I think my father will be pleasantly surprised with the challenge to get to his fathers day gift, :-P.