Guess My Number

Before going into the narrative of how the week went, here's documentation for this little game.

The toy will blink 4 times when it has thought of a number for you to guess.

It is thinking of 4 digit binary number.

Guess the number by pressing left button for 1's and right button for 0's. Enter all four digits to make a guess.

For example, if you wanted to guess 1100 (the number twelve), you would press left, left, right right.

The toy will give you hints about the number you guess.

If you guess the number, it celebrates with set of happy fast flashes.

Too many wrong guesses and you lose. It will put the lights on flat for a bit.

After one game is finished, it will start again with a new number to guess.

Demo Video

Work Log

I used my board from the electronics design week. I had put in two switches and two LEDs, thinking that this would allow me to do make a minimal little game of some sort for my daughter.

First step was to confirm the board worked. I used Neil's hello world echo code for this, which worked fine.

I then wanted to confirm that I could turn the lights on and off. I followed Erik's excellent notes from last year, but was confused for a bit when the LEDs didn't light up. I then noticed that he was using DDRB to set up the output pins, while mine needed to be using DDRA. That fixed it, and I was happy to see both lights turn on.

I then made them blink back and forth, using this code blink_one.c and makefile.

The lights did indeed blink, which was satisfying.

I then coded up the game described above. I should say here that my use of the term game comes from an archaic usage of this term stemming from the late 1970s in which small electronic boxes contianing blinking LEDs were widely mistaken for video games and given names like Electronic Football.

The game I put together was a "guess my number" game.

Code is here: guess_my_number.c and makefile.

A few points to mention: