E2 Problem involving buttons

I am relatively new to E2 and Wire in general but I feel I am starting to get it under my belt (Due to coding C++ for a year or so now)

My question regards buttons, for example, I have a timed explosive with a button to activate it, when a value is incremented to 5 (For example) the explosive will detonate. But, try with all my might, I cannot get the button to reset itself back to zero. I have heard that you need to involve using “Set”, but so far it has come to no avail…

On a side note, is there a more efficient method to create a “timer” without incrementing a value?

If somebody could shed some light it would be most appreciated. Also, apologies for how long-winded this is, I just wanted to cover as much of it as I can.

Below is a faux code I just knocked up to demonstrate how I have gone about doing it previously, incorrect of course.



@name Timed Explosive
@inputs Button
@outputs Detonate
@persist Timer
interval(1000)

if(Button==1) {Timer++}
if(Timer==5){Detonate=1}
if(Timer<=5){Timer=0, Button=0}
else{Detonate=0}


It has been 12 hours, so time for a lil’ bump

If I understand you correctly, your problem is you cannot change the button’s value back from 1 to 0, at least without pushing it yourself? As far as I know, the only way to do it in an automatic way is a wire user aimed at the button.

As for your timer, examine these myriad options.

Ah thanks for the advice and link.

With that in mind, my timer will only work if the value is set to 1 (Because it increments the value), therefore when the script is finished it will just keep looping until the button is pressed again.

Is there anyway for the timer to run when the button is un-toggled (I believe that is when you press it, it switches to 1 then straight back to 0)?


@name Simple timer
@inputs Button
@outputs Explode
@persist Toggle

if(clk("Reset")){
    Explode = !Explode
}

if(Button){
    Toggle = !Toggle
}

if(Toggle){
    timer("Explode",5000)
}

if(clk("Explode)){
    Explode = !Explode
    timer("Reset",1000)
}

Buggzie, would you mind explaining what this means? I am not accustomed to the clk() or ! operators. Nor do I understand why you are ‘resetting’ the timer to 1000…

And thanks by the way, I think I am catching the drift of it anyway.