Using a button

I would like to start off by saying I am new to the arduino world. I have been playing with the raspberry a lot but just now diving into the arduino world. I have purchased a Mega, Uno and Nano. I need help with a project I am working on with the raspberry, I want to see if arduino is more reliable as the raspberry has been kinda flaky with this project. Can someone please help me with a sketch? Basicly what I need is when I press a button 3 times within a 5sec time frame it turns a relay high. Then when I press it again 3 times in a 5sec time frame the makes the relay go low. If the relay goes hi and is not activated again to go low then it automatically goes low after 15mims. I feel like this is a easy sketch to make (it was for raspberry) but just have no idea how to start with arduino and this project is kinda time sensitive. If someone could please give me a hand it would be MUCH appreciated. Thank you for taking the time to read this!

Since you’ve done some programming it won’t take you long to read through the [u]Arduino Language Reference[/u].

Then start with the [u]Blink Example[/u], which is the Arduino equivalent of “Hello World”. It will show you how to make a basic delay() and since it uses the built-in LED it doesn’t take any additional hardware.

Program execution pauses during delay() and since you’ll need to read the button during the delay you can’t pause processing, so study the Blink Without Delay Example.

Then, hook-up a button and run the [u]Digital Read Serial Example[/u].

From there you might try making a button-press counter. You’ll need an extra little delay (or some kind of debounce) because you may get several pulses when you press the button once.

In order to drive a regular relay you’ll need a relay driver circuit (or a relay board with a built-in driver) because the Arduino can only put-out 5V at 40mA maximum, and that’s not enough for most relay coils.

…then it automatically goes low after 15mims.

You’ll want to shorten that up during testing/debugging so you can run more than 4 tests an hour. :wink:

as the raspberry has been kinda flaky with this project.

Any computer or microcontroller will be very reliable as long as there are no hardware or software bugs. (A relay can cause glitches on the power supply lines, if your problems were happening when the relay switched.)

Thank you for the info. Im going to give this a try right now. I really appreciate your time and knowledge.