Help needed for project.

Hello, newbie here :P.

My electronics teacher gave me a project, and the project is basically if I press a button 3 within a 10 second time limit, the LED must blink 3 times.

Any form of help is appreciated. I have already done the circuitry so I only need help in the programming section.

Hi Kengrove,
First, ill give you a few pointers on how to post on this forum.
First, you may want to make the title of your post more about your topic because "Help needed for project" does not really tell the people on the forums what you need help with.
Second, "newbie here" does not really help us know you skill at coding because different people have different standards for "newbie" rank.

To help you first your code, I don't have an exact code snippet, but try to make a variable that increases by 1 every time the button is pressed. Once it reaches 3, have the program wait 10 seconds and then go through a blink loop 3 times. delay(10000) Will have the program pause for 10 seconds (10000 is the number of milliseconds it will wait, which is 10 seconds).

You will have 3 steps:
-Detect 3 button presses
-Wait 10 seconds
-Blink 3 times

Follow up questions:
-Does the button press counter have to reset after the light blinks? or is it just a 1 time thing?
-Do the button presses have to be in a certain period of time?

First of all, thank you for your pointers.

For the first question, its not a one time thing, it must reset.
For the second, the button presses must be within a 10 second period.

Sorry for being unclear with my post.

@kengrove, there are two separate parts to your problem and you should figure them out separately.

The easy part is how to make an LED blink 3 times. Write a little program to make that happen. Look at the Blink without delay example in the Arduino IDE.

The other part is to figure out if there are 3 separate button presses within 10 seconds. (I presume 2 is wrong and 4 is wrong). This is just a little trickier.

You need to read the value of the I/O pin connected to the button and if the button is pressed you need to save the value of millis() and add 1 to a counter. Then you need to check if the button is released and pressed again - in which case add another 1 to the counter. You can print the value of the counter on the Serial Monitor so you can see what is happening.

Then you need to check if 10 seconds has elapsed since you saved the value of millis(). If it has you need to check the value of the counter. If it is 3 you have won, and can flash your LEDs. However, to start with keep it simple and just print the word "won" on the Serial Monitor.

When you have the two parts working separately you can think about merging them.

Have a look at Planning and Implementing a Program

...R

Robin2:
@kengrove, there are two separate parts to your problem and you should figure them out separately.

+1

Always break your problem into different components and then write in English (or your language of choice), what needs to happen and then and only then slowly turn it into code. So you clearly have a couple of timer issues. Google will give all your answers once you have decided what you need to do.