reading values in ms ?

Hi friends. how can I writing a sketch to reading the values in ms ? for example if A0 values in 100ms >= 250 then turning on LED.

thanks.

Are you saying “if A0 returns readings of greater than 250 for at least 100ms, then turn on LED” ?

TheMemberFormerlyKnownAsAWOL:
Are you saying "if A0 returns readings of greater than 250 for at least 100ms, then turn on LED" ?

thanks for reply. Yes that's right

So, use a clock.
Every time the reading on A0 is BELOW 250, reset the clock.
If the time now, minus the time you reset the clock is >= 100ms, light the LED.

TheMemberFormerlyKnownAsAWOL:
So, use a clock.
Every time the reading on A0 is BELOW 250, reset the clock.
If the time now, minus the time you reset the clock is >= 100ms, light the LED.

can you write this as arduino sketch for me ? :sweat_smile:

thanks.

Yes, but that would be no fun for you.

TheMemberFormerlyKnownAsAWOL:
Yes, but that would be no fun for you.

thanks. but I'm new to arduino programming.

Great way to learn.

TheMemberFormerlyKnownAsAWOL:
Great way to learn.

:)) is it true ?

#define CYCLEDURATION 100

void loop(){
  unsigned int _currentMicros = micros();
  if(_currentMicros - _previousMicros > CYCLEDURATION) {

}

Something like this pseudo code

if value > 250 
   lastTimeValueWasHigh = millis()


if (millis() - lastTimeValueWasHigh >= 100) {
  // value has been low for 100 msecs
  // do something

...R