555 Timer Equivilent

Hi Everyone

I had been planning a project using a couple of 555 timers to blink a LED for a minute after a button is pressed then turn it off and wait for the button to be pushed again. I would also like to be able to stop the flashing at any point and turn off the LED. But after a bit of thinking this seems like something that would be much more flexible if done on an Arduino.

I have done a little research and found the blink without delay tutorial using millis() which looks ideal, and obviously the button tutorial. However i am not sure how combine these to trigger the LED from a button then stop the flashing and turn off the LED after a minute?

If anyone could offer any advise it would be greatly appreciated. :slight_smile:

If anyone could offer any advise it would be greatly appreciated.

You've got a pencil, a watch, and a pad of paper. The user has a stick to whack you with. How would YOU perform the task, after the user whacks you with the stick?

First, you need to detect being whacked. That really isn't too hard to determine, is it? Look at the state change detection example if inspiration is needed.

OK. Now that you know it is time to get to work, knowing that you will only be working for some period of time, what do you need to do, to assure that you quit on time? Can you do that with the equipment you have? (Of course, you can.)

The pencil is the Arduino's equivalent of being able to store data in a variable. The pad of paper is the Arduino's equivalent of memory space where variables live. The watch is the Arduino's equivalent of the millis() function.

What if the button is pressed during the one minute blinking? Do you want to ignore it? Reset the one minute from that time? Do something else (eg: increase the time by 10 seconds)?

Further to PaulS' advice, there is one small complication. You have a pencil, a watch, a pad of paper, and you are a goldfish with a 50 microsecond attention span. The whole world consists of the question "what am I supposed to be doing right now?", which you re-ask yourself every 50 microsecond.

In this case, you can look to see if someone is whacking you with the stick (you see everything in really slow motion, the stick actually takes several cycles to complete a whack), you can look at the time, you can read your pad of paper, and from those three things you have to decide what to do: you can turn the LED on or off (or leave it as it is), and you can write down a reminder note, eg "I most recently turned the LED on when the time was 54321, and I last got whacked with a stick back when the time was 32109".

boolean flashing = false;
boolean currentFlashState;
unsigned long startFlashingMs;
unsigned long startCurrentFlashMs;

setup() {
  set up the input and output pins
}

loop() {
  // step 1 - look at button, start flashing if it's down, stop flashing if its up AND we have been flashing for a minute

  // step 2 - if we are currently flashing, then if it's been 500ms since we started this flash, then reverse 
  //              the state of the LED, making a note of the current time (or just add 500ms)

  // step 1 and 2 can be done in any order
}

and you are a goldfish with a 50 microsecond attention span.

I'm going to have to add that to my analogy in the future. 8)