Re '...several things at the same time'

That would just make it blink faster.

I'm simply asking why it doesn't do what @Robin2 says here (my bold highlighting):

"// this sketch does the following
// it blinks the onboard LED (as in the blinkWithoutDelay sketch)
// it blinks two external LEDs (LedA and LedB) that are connected to pins 12 and 11.
// it turns another Led (buttonLed connected to pin 10**) on or off whenever a button**
// connected to pin 7 is pressed
Still hoping to hear what behaviour others get.

'erratic' and 'unpredictable'

Code is generally neither erratic or unpredictable
It sounds more like a hardware/wiring problem or a misunderstanding of what the code is intended to do

It doesn't remain in one state with the button held down, because it lacks state change detection. That is because, as I observed before, it is a simple demo that is not intended to finesse the operation of a switch. The sketch is about multitasking. There is nothing else that you can learn from this. Well, you learned that you need state change detection for a real switch application...

State change detection tells you when something becomes so, as opposed to when it is so.

UKHeliBob:
Code is generally neither erratic or unpredictable
It sounds more like a hardware/wiring problem or a misunderstanding of what the code is intended to do

UKHeliBob:
Code is generally neither erratic or unpredictable
It sounds more like a hardware/wiring problem or a misunderstanding of what the code is intended to do

I quoted verbatim what it was intended to do. The discussion is about why it doesn’t do it.

Robin2:
It's a long time since I wrote and tested the Tutorial code. I don't recall needing to hold the button press for long but it might be a good idea to change

const int buttonInterval = 300; // number of millisecs between button readings

to

const int buttonInterval = 50;

...R

But you didn’t use a button according to these comments:

// On my Uno and Mega the "button" is just a piece of wire inserted into pin 7.
// Touching the end of the wire with a moist finger is sufficient to cause the switching action
// Of course a proper press-on-release-off button switch could also be used!

As described, I did use a proper button.

aarg:
It doesn't remain in one state with the button held down, because it lacks state change detection. That is because, as I observed before, it is a simple demo that is not intended to finesse the operation of a switch. The sketch is about multitasking. There is nothing else that you can learn from this. Well, you learned that you need state change detection for a real switch application...

State change detection tells you when something becomes so, as opposed to when it is so.

I assume that’s a reply to Blackfin? I am not holding a pb down!

aarg:
That would just make it blink faster.

Yes, that’s what it does here.

It is true that the comments don't fully explain the code. What kind of resolution are you hoping for here? You want the author to go back and modify the code or else the comments? You should give some reasons for either.

aarg:
It is true that the comments don't fully explain the code. What kind of resolution are you hoping for here? You want the author to go back and modify the code or else the comments? You should give some reasons for either.

What I was expecting to get was just an answer to my original question. So that I knew whether it was some novice mistake I was making and could then fix it and learn from it. Ideally from the tutorial’s author, Robin.

But I assumed it would also be a simple matter for any of the other experienced users here to try it. Either reproducing the same behaviour or suggesting an explanation, pending a definitive reply from Robin.

My tentative conclusion so far is that the code doesn’t do what was claimed, so it would be good to see an edit that fixed that flaw.

aarg:
That would just make it blink faster.

You are correct. In my ageing memory I thought I had just created it as a debounce interval.

Having loaded the Tutorial program onto my Uno I have concluded that my description of how the switch controls the LED is incorrect. In reality the LED flashes while the switch is pressed. It’s a bit of luck whether it can be made to change from permanent OFF to ON or vice versa.

…R

PS … it’s interesting that it has taken 6 years for this to come to light :slight_smile:

Thanks Robin, appreciate the explanation; that had me fretting for most of yesterday! :wink:

I was surprised that the thread seemed to end abruptly in 2014? There were probably hundreds of user like me who studied it and ran it during those six years and I’m sure someone else must have had comments of some kind?

Terry

Terrypin:
I was surprised that the thread seemed to end abruptly in 2014?

The Thread is locked so people cannot add to it. That is deliberate. If dozens of people add questions and answers it would be very difficult to find stuff.

The idea is that if you have a question you start your own Thread and refer back to the Tutorial - as you have done.

...R