Arduino input state sense

Sir,

I am new in programming, I need a help, I want an Arduino output become high only if an input blink

(high-low ) continuously.If the input stay high or low , the output will be zero

Thanks

Have you played with the blink , digital input examples in the IDE to learn a bit about coding ?

Have a try and experiment

You are missing a definition, how long in the same state do you classify as steady on?

Pseudo code:

if(inputChanged){
  digitalWrite(OutputPin, HIGH);
  lastInputChangeMillis = millis();
}

if(digitalRead(OutputPin) && (millis() - lastInputChangeMillis >TimeoutInterval)){
  digitalWrite(OutputPin, LOW);
}

Don't really have to do much to turn it into real code :wink:

Thank you for your reply, how long the input state steady depends how long the arduino connected with

Wi-Fi network. I am sorry still I didn't understand the code.

Thank you

sat001:
Thank you for your reply, how long the input state steady depends how long the arduino connected with Wi-Fi network.

Uhm, something most specify when something is blinking and when you call it steady. Is 1 second on, 1 second off blinking? What about 2 seconds? 10 seconds? 1 minute? An hour?

You're planning this project so you should define what your need is :wink:

sat001:
I am sorry still I didn't understand the code.

It's pretty simple (pseudo) code. If you don't understand it then I think you don't understand any programming, do you? I would suggest to start with a simple tutorial :slight_smile:

sat001:
Wi-Fi network. I am sorry still I didn't understand the code.

That code, is basic at its best. If you do not understand what the code is doing, I suggest that you read up on programming.

Here is a link to help get you started. Once you understand the basics life will be easier.

Even though I am not expert in programming I am managed to run two project, related to home

automation.It is working fine for last few years.Any how, thank you.

sat001:
I need a help, I want an Arduino output become high only if an input blink

(high-low ) continuously.If the input stay high or low , the output will be zero

Build a timer which runs when signal is true, resets when signal is false. If timer reaches preset the signal stayed on too long. Build another timer but with signal inverted. If this second timer reaches preset the signal stayed off too long. Either timer timed out means signal is no longer changing. Basically a DIY watchdog timer.

Or, use the change of state of signal to reset a single timer. If timer reaches preset...

const byte BlinkingInputPin = 2;
const byte AlarmOutputPin = 3;

const unsigned long AlarmInterval = 1000; // A value somewhat longer than the blink interval

void setup()
{
  pinMode(BlinkingInputPin, INPUT_PULLUP); // Using pullup in case of disconnect
  pinMode(AlarmOutputPin, OUTPUT);
}

void loop()
{
  static boolean previousInputState = LOW;
  static unsigned long previousBlinkTime = 0;

  boolean currentInputState = digitalRead(BlinkingInputPin);
  unsigned long currentTime = millis();

  if (currentInputState != previousInputState)
  {
    // A blink is happening (the input pin just turned ON or OFF)
    previousInputState = currentInputState;
    previousBlinkTime = currentTime;  // Reset the alarm timer
    digitalWrite(AlarmOutputPin, LOW);  // Make sure the alarm is off
  }
  else
  {
    // The input pin has not just changed.  See if has been unchanged too long.
    if (currentTime - previousBlinkTime >= AlarmInterval)
    {
      // The input stopped blinking!  Sound the alarm!
      digitalWrite(AlarmOutputPin, HIGH);
    }
  }
}

Thanks a lot, let me try the code.