Reaction Challenge Game(Dexter Serrao)

When the reaction challenge game was first mentioned I had immediately began coming up with ideas for a potential game. I decided that I wanted to do something that involved both reaction and memory. My game was going to show a pattern meant to be memorized, then it would cycle through 16 unique patterns randomly. If the button was pressed while the original pattern is shown then you win the game and a light will turn on to indicate you won, and the whole thing would start over, getting faster as you succeeded.

I ran into my first wall with the random function. every time I ran my sketch I would get the same patterns, it would appear random at first but it would always be the same random patterns. I did some research and found that you can choose a random seed by giving it the value of an unused analog pin.(apparently the unused pin will be reading different values each time you run your sketch making the random seed different every time). This allowed me to get real randomness in the changing of patterns.

The next wall I faced was with the delay function. I quickly learned that with the delay function it becomes very hard to work with and read the buttons input accurately. luckily we learned about state machines not long after and I figured out that I would need to structure my sketch differently if I wanted it to work.

state-machine-diagram

Once I attempted to make the game using state machines everything fell into place nicely. The last issue I had was that when randomly selecting a pattern, it was possible that extended periods of time could pass without ever displaying the target pattern. I solved this problem by using a counter variable that would force the pattern to display after a random amount of patterns have been displayed.

Below is what the final product looks like:reaction-challenge

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s