I made a game.
- Press button when middle LED is on
- Points get per hit depend on how fast the wave is going (1 to maximum of 7)
- Speed of the wave increases as time elapses. It is also adjustable at any time with the potentiometer
- At 30 seconds remaining, player gets alerted (LEDs blink and Processing display starts pulsing)
This took a week! The idea was simple but wrapping my head around how to actually code it took some time. I was surprised at this, but learned a lot in the process.
Hardware interrupt vs. continuous polling,
When the push button is pressed, you want something to happen( for example calling a function to check if the middle LED is on ). With a hardware interrupt this is easy. However to use a hardware interrupt, you also need to use hardware debouncing for the push button and I didn’t have the necessary components on hand. I opted to instead use a simple
delay() to account for bounce, and continuous polling to detect if the button was pressed. That is, every 100 seconds or so, I called
checkPress() to get the state of the button (pressed or !pressed).
Also, if you have an idea, go for it. It might not turn out to be as straight forward as you thought but YOLO the journey is often worth it.