"Hey, this is not real programming, we're just using ready-made code!"
In this exercise the students don't write the whole code themselves.
The comment above "copying code is not real programming" came from a
real-life secondary school student, and it makes sense if you're just
starting with programming.
Using ready-made code in this exercise serves many purposes.
- You learn to appreciate what you already know: you understand big
chunks of the code already. You also learn not to panic when you
don't understand everything (which is common for pretty much all
programmers!)
- You learn to appreciate other people's code: willingness to share
cool things helps the whole community of programmers and makers. We
made this game at Mehackit and shared the code to be used as a basis
for further creation. The code is shared under the Creative Commons
Licence CC-BY-2.0,
which means you can use this code as the basis for your own work as
long as you give credit to the original creator.
- Using ready-made code is a real world practice: programmers seldom
start with an empty IDE window, from line 0. They rely a lot on
libraries, code examples and code already produced in other projects
they or their colleagues have been working on.
- You get an idea of what you can make with Arduino! You don't learn
how to write this whole code by yourself, but the experience of
having made a reaction game remains. You can return to this project
later on, or use it and develop the idea in a new context.
Extra features & ideas
The students may not have the skills to code all these features right
away, but feel free to return to the exercise after finishing
Electronics & Programming basics!
- Keep track of the score
You'll need a variable to store every correct button press. In the
program, there's the variable questionIndex
which stores this
information! You could print this to the serial monitor (see next
chapter for instructions), or connect an LCD display and have it
show the score - High score
You need a variable for the high score. Also, you need to store the
final score of each finished game and compare it with the high
score. If the latest score is higher than the high score, it is
stored into the high score variable.
You can print the high score eg. into the serial monitor or an LCD
display. - Sounds
Identify the piezo pin number from the code, connect the piezo and
check what sounds the game makes. Make better sounds with the tone
command. You can also add a melody into the gameOver
section! - Change the timing of events
Identify the variables that deal with timing the game events. Modify
them and change the difficulty of the game. - Different game controls
What should the game be played with? A mallet, feet, magnets?
Replace the pushbuttons with self-made switches or some other type
of switches for a completely different game experience. - Casing
Design and build a structure to hide the electronics and to present
the LEDs and game controls in a nice way! - You name it!
There's no way to list all the possible modifications - go ahead
and imagine new hacks!