Electronic target system > Seeking advice on technical choices !

Good work!

But when I take your link, I get the simple sketch. IDK if that's because of I don't know why.

Anyway, I can read the code and see what it does, probably.

There are a few stray harmless semicolons finding themselves after a closing brace };.

Watch out for those, don't use semicolons when they are not needed though harmless. Sometimes stray semicolons can cause problems (bugs), and having them makes a reader wonder. You can harmlessly strew semicolons, they are just noise. A distraction.

Next, and just an observation, this does spam the serial monitor. There are a number of good ways to cut that down, I'll save that for later.

The LED will be on as long as you are holding the button down, and then for three two (!) more seconds, unless you get your finger back on the button.

The desired behaviour is that the act of pushing the button down initiates a N second LED burst. So even if you have the button held, the LED goes off. If during the LED on phase you release and press again the button, it will be N seconds from the moment you again pressed the button until the LED goes off.

This is a tiny example of how one must think through and completely work out all the things that can happen, and what the specific functionality is to be.

The basic concept that will help you is called "state change detection" (or "edge detection") which concerns itself with the fact that a button becomes pressed rather than that it is being held pressed. The other edge is the release of the button, when we could say it becomes unpressed, if we said anything at all about that event.

There's a crap-ton of state change detection tutorials. Google is your friend. Read this post and the thread it finds itself on:

and this thread

for a good start.

Thanks for your implicit trust that these small exercises will pay off in the long run.

a7