Can I "reset" the timeout of the timeout Bit?

I want to build an “open door detection system”, using a switch Bit and a timeout Bit to activate a buzzer Bit if the door is left open more than 10 seconds.

However, when I open and close the door within 10 seconds, the next time I open the door, the buzzer Bit starts to buzz immediately. This is not what I want the system to do.

I did some testing, and found out that my problem is the timeout Bit, because it doesn’t seem to reset itself when you send another signal within the initial timeout.

This is my test setup:

  • When I press the button, the leds light up for 3 seconds and then turn off again. This is as expected, because the timer Bit is set to “on-off” mode and the timer set to 3 seconds.
  • Now when I press the button and press it again 2 seconds after the first press, the leds turn off again only 1 second after my second press… I expected it to turn off 3 seconds after my second press.

So it seems the timeout Bit doesn’t reset its timeout when you send another signal within the initial timeout (on or off, depending on the mode of the timeout Bit).

Is this a bug? Is there a workaround?

Hi @DionoiD,
welcome to the forum !
I checked your circuit and found the following for you:
It is not a bug… :ant:
The time-out bit starts its sequence and finishes it without looking at the input during the sequence.
So it cannot be reset (exept by removing the power, but that might not be what you want…)
I tried the following alternative circuit, it does exactly what you want:

It is built up with the Littlebits Arduino.
Press the button and the counter starts counting and will be reset when the button is released before 10 seconds pass.
Only when the button is continuously pressed for 10 seconds or more the LED will light up for three seconds.
This is the Arduino program I used (very quick design)
It might seem a little overdone to use the Arduino, but I could not find another solution… :joy_cat:

// open door alarm
// alex pikkert june 2016
// power+button on A0 input
// Bargraph LED on D5 output
// When button is pressed more than 10 seconds the LED will light up for 3 seconds

int count;

void setup() {
// put your setup code here, to run once:

pinMode(5,OUTPUT);
pinMode(A0,INPUT);
}

void loop() {
// put your main code here, to run repeatedly:

if(digitalRead(A0)==HIGH)
{count = count +1;
delay(1000);

if(digitalRead(A0)==LOW)
{count = 0;}

if(count==10)
{
digitalWrite(5,HIGH);delay(3000);digitalWrite(5,LOW);
}
}
}

Thanks for your reply, @alexpikkert. Good to meet a fellow Dutchman on the forum!
I also figured out the Arduino Bit is probably the only way to solve this… Still I think this is a “design-flaw” of the timeout Bit. :unamused:

Your sketch will surely give me a head start solving this. Thanks!! :+1:

1 Like