Invoke two events

I have the following code. I would like to have the ledAlarm (pin 6) blink continuous if the analogValue < threshold and the ledPin just remain on constant.
I have the constant working but not the other.

I am new and tried a few things, got upset and just have it blink 4x.
I’m going to continue to try and figure out.
Any help or guidance would be greatly appreciated.

// constants won't change. Used here to set a pin number:
const int ledAlarm =  6;// the number of the LED pin
const int analogPin = A0;    // pin that the Solar panel is attached to
const int ledPin = 13;       // pin that the Alarm is attached to
const int threshold = 90;   // The threshold level that is between the solar value readings when the laser is in contact vs when the laser is off.
                             // change threshold value to calabrate alarm system

// Variables will change:
int ledState = LOW;             // ledState used to set the LED


void setup() {
  // set the digital pin as output:
  pinMode(ledPin, OUTPUT);
  pinMode(ledAlarm, OUTPUT);
  
  // initialize serial communications:
  Serial.begin(9600);
}


void loop() {
  // here is where you'd put code that needs to be running all the time.

  // check to see if it's time to blink the LED; that is, if the difference
  // between the current time and last time you blinked the LED is bigger than
  // the interval at which you want to blink the LED.
   int analogValue = analogRead(analogPin);

  // if the analog value is high enough, turn on the LED(alarm):
  
  if (analogValue < threshold) {
    digitalWrite(ledPin, HIGH);
   { digitalWrite(ledAlarm,HIGH);
   delay(250);
   digitalWrite(ledAlarm,LOW);
   delay(250);
digitalWrite(ledAlarm,HIGH);
   delay(250);
   digitalWrite(ledAlarm,LOW);
   delay(250);
digitalWrite(ledAlarm,HIGH);
   delay(250);
   digitalWrite(ledAlarm,LOW);
   delay(250);
digitalWrite(ledAlarm,HIGH);
   delay(250);
   digitalWrite(ledAlarm,LOW);
   delay(250);
digitalWrite(ledAlarm,HIGH); 
  }}

 
      // print the analog value:
  Serial.println(analogValue);
  delay(500);        // delay in between reads for stability
  
  }

Investigate how to use millis() and do several things simultaniously.

ok, I will, thank you

Start from the BlinkWithoutDelay example sketch. You can't fix this one.

There is and example in the IDE that shows how to use a technique called BWD, blink without delay.
This example demonstrates how to get rid of delay().

Next look at Robin2’s discussion here:

I started fresh with the BlinkWithoutDelay as suggested…TY

Before anything happens, the “analogValue” must be less than the Threshold.

So doesn’t that have to be the first thing in the loop?

Then I followed it up with the remaining “BlinkWithoutDelay” code.

Sorry, just frustrating, been at it for hours now.

/*
  Blink without Delay

  Turns on and off a light emitting diode (LED) connected to a digital pin,
  without using the delay() function. This means that other code can run at the
  same time without being interrupted by the LED code.

  The circuit:
  - Use the onboard LED.
  - Note: Most Arduinos have an on-board LED you can control. On the UNO, MEGA
    and ZERO it is attached to digital pin 13, on MKR1000 on pin 6. LED_BUILTIN
    is set to the correct LED pin independent of which board is used.
    If you want to know what pin the on-board LED is connected to on your
    Arduino model, check the Technical Specs of your board at:
    https://www.arduino.cc/en/Main/Products

  created 2005
  by David A. Mellis
  modified 8 Feb 2010
  by Paul Stoffregen
  modified 11 Nov 2013
  by Scott Fitzgerald
  modified 9 Jan 2017
  by Arturo Guadalupi

  This example code is in the public domain.

  http://www.arduino.cc/en/Tutorial/BlinkWithoutDelay
*/

// constants won't change. Used here to set a pin number:
const int ledPin =  LED_BUILTIN;// the number of the LED pin
const int analogPin = A0;    // pin that the Solar panel is attached to
const int threshold = 90;   // The threshold level that is between the solar value readings when the laser is in contact vs when the laser is off.
                             // change threshold value to calabrate alarm system

// Variables will change:
int ledState = LOW;             // ledState used to set the LED

// Generally, you should use "unsigned long" for variables that hold time
// The value will quickly become too large for an int to store
unsigned long previousMillis = 0;        // will store last time LED was updated

// constants won't change:
const long interval = 1000;           // interval at which to blink (milliseconds)

void setup() {
  // set the digital pin as output:
  pinMode(ledPin, OUTPUT);
  // initialize serial communications:
  Serial.begin(9600);
}

void loop() {
  // here is where you'd put code that needs to be running all the time.

  // check to see if it's time to blink the LED; that is, if the difference
  // between the current time and last time you blinked the LED is bigger than
  // the interval at which you want to blink the LED.

  int analogValue = analogRead(analogPin);

  // if the analog value is high enough, turn on the LED(alarm):
  if (analogValue < threshold) {
    digitalWrite(ledPin, HIGH);


  
  unsigned long currentMillis = millis();

  if (currentMillis - previousMillis >= interval) {
    // save the last time you blinked the LED
    previousMillis = currentMillis;

    // if the LED is off turn it on and vice-versa:
    if (ledState == LOW) {
      ledState = HIGH;
    } else {
      ledState = LOW;
    }

    // set the LED with the ledState of the variable:
    digitalWrite(ledPin, ledState);
  
        
  } 

  
  // print the analog value:
  Serial.println(analogValue);
  delay(500);        // delay in between reads for stability
  }
}

Pin 13 begins to blink a constant blink upon start. (but i’m investigating why because it doesn’t meet the analogValue < threshold in line before it.

Pin 6 waits for the threshold and remains on constant like wanted.

Hopefully i’m on the right track now.

/*
  Blink without Delay

  Turns on and off a light emitting diode (LED) connected to a digital pin,
  without using the delay() function. This means that other code can run at the
  same time without being interrupted by the LED code.

  The circuit:
  - Use the onboard LED.
  - Note: Most Arduinos have an on-board LED you can control. On the UNO, MEGA
    and ZERO it is attached to digital pin 13, on MKR1000 on pin 6. LED_BUILTIN
    is set to the correct LED pin independent of which board is used.
    If you want to know what pin the on-board LED is connected to on your
    Arduino model, check the Technical Specs of your board at:
    https://www.arduino.cc/en/Main/Products

  created 2005
  by David A. Mellis
  modified 8 Feb 2010
  by Paul Stoffregen
  modified 11 Nov 2013
  by Scott Fitzgerald
  modified 9 Jan 2017
  by Arturo Guadalupi

  This example code is in the public domain.

  http://www.arduino.cc/en/Tutorial/BlinkWithoutDelay
*/

// constants won't change. Used here to set a pin number:
const int ledPin =  LED_BUILTIN;// the number of the LED pin
const int analogPin = A0;    // pin that the Solar panel is attached to
const int threshold = 90;   // The threshold level that is between the solar value readings when the laser is in contact vs when the laser is off.
                             // change threshold value to calabrate alarm system
const int ledAlarm = 6;

// Variables will change:
int ledState = LOW;             // ledState used to set the LED

// Generally, you should use "unsigned long" for variables that hold time
// The value will quickly become too large for an int to store
unsigned long previousMillis = 0;        // will store last time LED was updated

// constants won't change:
const long interval = 1000;           // interval at which to blink (milliseconds)

void setup() {
  // set the digital pin as output:
  pinMode(ledPin, OUTPUT);
  pinMode(ledAlarm, OUTPUT);
  // initialize serial communications:
  Serial.begin(9600);
}

void loop() {
  // here is where you'd put code that needs to be running all the time.

  // check to see if it's time to blink the LED; that is, if the difference
  // between the current time and last time you blinked the LED is bigger than
  // the interval at which you want to blink the LED.


  int analogValue = analogRead(analogPin);

  // if the analog value is high enough, turn on the LED(alarm):
  
 if (analogValue < threshold) 
    digitalWrite(ledAlarm, HIGH);

  {
  unsigned long currentMillis = millis();

  if (currentMillis - previousMillis >= interval) 
    // save the last time you blinked the LED
    previousMillis = currentMillis;

    // if the LED is off turn it on and vice-versa:
    if (ledState == LOW) {
      ledState = HIGH;
    } else {
      ledState = LOW;
    }

    // set the LED with the ledState of the variable:
    digitalWrite(ledPin, ledState);
  }
 
        
 

  
  // print the analog value:
  Serial.println(analogValue);
  delay(500);        // delay in between reads for stability
  }

if (analogValue < threshold)

Everything you want to happen if the condition is true needs to be enclosed in {}. Otherwise, only the next line is executed.

https://www.arduino.cc/reference/en/language/structure/control-structure/if/

Having supper so I can offer this example of doing several things at once.
You might get some ideas from this.

//Simple BWD BlinkWithoutDelay examples
//
//Timer variables used
unsigned long currentMillis;
unsigned long pin13Millis;
unsigned long pin12Millis;
unsigned long SwitchMillis;
 
//if these are not changed in the sketch, they can be const
unsigned long debounceMillis = 50UL;  //50ms
unsigned long ledOnTime      = 500UL; //500ms seconds
 
byte lastSwitchState = HIGH;
byte buttonState     = HIGH;
 
//enable/disable flags
boolean flag13 = true;
boolean flag12 = false;
 
const byte Switch = 2; //pushed = LOW
 
//**********************************************************************
 
void setup()
{
  Serial.begin(9600);
 
  digitalWrite(13,LOW);
  pinMode(13, OUTPUT);
  
  digitalWrite(12,LOW);
  pinMode(12, OUTPUT);
 
  pinMode(Switch, INPUT_PULLUP); //pushed = LOW
 
} //  >>>>>>>>>>>>>> E N D  O F  s e t u p ( ) <<<<<<<<<<<<<<<<<
 
void loop()
{
  //save the current time
  currentMillis = millis();
 
  //*************************************
  //Heartbeat LED
  //Toggle LED on and off. Helps show if there is blocking code
  if (flag13 == true && currentMillis - pin13Millis >= ledOnTime)
  {
    pin13Millis = millis();            //re-initialize Timer
    digitalWrite(13,!digitalRead(13)); //toggle LED condition
  }
 
  //*************************************
  if (flag12 == true && currentMillis - pin12Millis >= 5*1000UL)
  {
    //Turn off pin 12
    digitalWrite(12,LOW); //Turn off LED
    flag12 = false;       //disable timing
  }
 
//*************************************
//is it time to check the switches?
if (currentMillis - SwitchMillis >= debounceMillis)
{
//code here runs every debounceMillis ms
SwitchMillis = millis(); //re-initilize Timer

//go and check the switches
checkSwitches();   
}
 
  //*********************************
  //put other non-blocking stuff here
  //*********************************
 
} //  >>>>>>>>>>>>>> E N D  O F  l o o p ( ) <<<<<<<<<<<<<<<<<
 
 
//======================================================================
//                      F U N C T I O N S
//======================================================================
 
 
//****************** c h e c k S w i t c h e s ( ) *********************
//switches are checked every debounceValue milli seconds
//no minimum switch press time is validated with this code (i.e. No glitch filter)
void checkSwitches() 
{
  //re-usable for all the switches 
  boolean thisState;   
 
  //check if this switch has changed state
  thisState = digitalRead(Switch);
  if (thisState != lastSwitchState)
  { 
    //update the switch state
    lastSwitchState = thisState; 
 
    //this switch position has changed so do some stuff
    //"LOW condition code"
    //has switch gone from HIGH to LOW?
    if(thisState == LOW)                         
    {
      //Do some LOW switch stuff here 
      flag12 = true;          //allow timing
      digitalWrite(12, HIGH); //turn on LED
      pin12Millis = millis(); //initialize Timer
    }
 
  } //END of Switch code
 
  //***************************************** 
  // similar code for other switches goes here
  //***************************************** 
 
} //END of checkSwitches()
 
//**********************************************************************
 
//======================================================================
//                      E N D  O F  C O D E
//======================================================================

TY, I enclosed everything I want to happen after the condition is true.

Upon meeting the condition now both pins go high, (good), but pin 13 does not blink continuous.

i did understand enclosing with brackets, TY.
Still pecking away at it.

/*
  Blink without Delay

  Turns on and off a light emitting diode (LED) connected to a digital pin,
  without using the delay() function. This means that other code can run at the
  same time without being interrupted by the LED code.

  The circuit:
  - Use the onboard LED.
  - Note: Most Arduinos have an on-board LED you can control. On the UNO, MEGA
    and ZERO it is attached to digital pin 13, on MKR1000 on pin 6. LED_BUILTIN
    is set to the correct LED pin independent of which board is used.
    If you want to know what pin the on-board LED is connected to on your
    Arduino model, check the Technical Specs of your board at:
    https://www.arduino.cc/en/Main/Products

  created 2005
  by David A. Mellis
  modified 8 Feb 2010
  by Paul Stoffregen
  modified 11 Nov 2013
  by Scott Fitzgerald
  modified 9 Jan 2017
  by Arturo Guadalupi

  This example code is in the public domain.

  http://www.arduino.cc/en/Tutorial/BlinkWithoutDelay
*/

// constants won't change. Used here to set a pin number:
const int ledPin =  LED_BUILTIN;// the number of the LED pin
const int analogPin = A0;    // pin that the Solar panel is attached to
const int threshold = 90;   // The threshold level that is between the solar value readings when the laser is in contact vs when the laser is off.
                             // change threshold value to calabrate alarm system
const int ledAlarm = 6;

// Variables will change:
int ledState = LOW;             // ledState used to set the LED

// Generally, you should use "unsigned long" for variables that hold time
// The value will quickly become too large for an int to store
unsigned long previousMillis = 0;        // will store last time LED was updated

// constants won't change:
const long interval = 1000;           // interval at which to blink (milliseconds)

void setup() {
  // set the digital pin as output:
  pinMode(ledPin, OUTPUT);
  pinMode(ledAlarm, OUTPUT);
  // initialize serial communications:
  Serial.begin(9600);
}

void loop() {
  // here is where you'd put code that needs to be running all the time.

  // check to see if it's time to blink the LED; that is, if the difference
  // between the current time and last time you blinked the LED is bigger than
  // the interval at which you want to blink the LED.


  int analogValue = analogRead(analogPin);

  // if the analog value is high enough, turn on the LED(alarm):
  
 if (analogValue < threshold) 
    {digitalWrite(ledAlarm, HIGH);

  
  unsigned long currentMillis = millis();

  if (currentMillis - previousMillis >= interval) 
    // save the last time you blinked the LED
    previousMillis = currentMillis;

    // if the LED is off turn it on and vice-versa:
    if (ledState == LOW) {
      ledState = HIGH;
    } else {
      ledState = LOW;
    }

    // set the LED with the ledState of the variable:
    digitalWrite(ledPin, ledState);}
  
   
  // print the analog value:
  Serial.println(analogValue);
  delay(500);        // delay in between reads for stability
  }

i did understand enclosing with brackets,

I enclosed everything I want to happen after the condition is true.

if (currentMillis - previousMillis >= interval)

What do you want to happen after this condition is true?

I think I see something to bring up here.

When the (analogValue < threshold) it should send 6 & 13 high, leaving 6 high and continuosley blink 13.

However, the (analogValue < threshold) will only be met once…then it goes right back up again. If the values were to remain (analogValue < threshold), then everything would work fine.

So I think this is throwing off how I’m looking at it.

Latest iteration:

/*
  Blink without Delay

  Turns on and off a light emitting diode (LED) connected to a digital pin,
  without using the delay() function. This means that other code can run at the
  same time without being interrupted by the LED code.

  The circuit:
  - Use the onboard LED.
  - Note: Most Arduinos have an on-board LED you can control. On the UNO, MEGA
    and ZERO it is attached to digital pin 13, on MKR1000 on pin 6. LED_BUILTIN
    is set to the correct LED pin independent of which board is used.
    If you want to know what pin the on-board LED is connected to on your
    Arduino model, check the Technical Specs of your board at:
    https://www.arduino.cc/en/Main/Products

  created 2005
  by David A. Mellis
  modified 8 Feb 2010
  by Paul Stoffregen
  modified 11 Nov 2013
  by Scott Fitzgerald
  modified 9 Jan 2017
  by Arturo Guadalupi

  This example code is in the public domain.

  http://www.arduino.cc/en/Tutorial/BlinkWithoutDelay
*/

// constants won't change. Used here to set a pin number:
const int ledPin =  LED_BUILTIN;// the number of the LED pin
const int analogPin = A0;    // pin that the Solar panel is attached to
const int threshold = 90;   // The threshold level that is between the solar value readings when the laser is in contact vs when the laser is off.
                             // change threshold value to calabrate alarm system
const int ledAlarm = 6;

// Variables will change:
int ledState = LOW;             // ledState used to set the LED

// Generally, you should use "unsigned long" for variables that hold time
// The value will quickly become too large for an int to store
unsigned long previousMillis = 0;        // will store last time LED was updated

// constants won't change:
const long interval = 1000;           // interval at which to blink (milliseconds)

void setup() {
  // set the digital pin as output:
  pinMode(ledPin, OUTPUT);
  pinMode(ledAlarm, OUTPUT);
  // initialize serial communications:
  Serial.begin(9600);
}

void loop() {
  // here is where you'd put code that needs to be running all the time.

  // check to see if it's time to blink the LED; that is, if the difference
  // between the current time and last time you blinked the LED is bigger than
  // the interval at which you want to blink the LED.


  int analogValue = analogRead(analogPin);

  // if the analog value is high enough, turn on the LED(alarm):
  
 if (analogValue < threshold) {
    digitalWrite(ledAlarm, HIGH);

  
  unsigned long currentMillis = millis();
 
 if (currentMillis - previousMillis >= interval) 
    // save the last time you blinked the LED
    previousMillis = currentMillis;

    // if the LED is off turn it on and vice-versa:
    if (ledState == LOW) {
      ledState = HIGH;
    } else 
      ledState = LOW;
    

    // set the LED with the ledState of the variable:
    digitalWrite(ledPin, ledState);
    }
   
  // print the analog value:
  Serial.println(analogValue);
  delay(500);        // delay in between reads for stability
  }

When you are using BWD, why do you have:
delay(500);

?

I think that's just to slow down the serial monitor readings so I can watch them.

delay() completely disrupts BWD.

Create another BWD section of code to handle slowing down the printing.

How about something like this:

const int ledPin =  LED_BUILTIN;// the number of the LED pin
const int analogPin = A0;    // pin that the Solar panel is attached to
const int threshold = 90;   // The threshold level that is between the solar value readings when the laser is in contact vs when the laser is off.
                             // change threshold value to calabrate alarm system
const int ledAlarm = 6;

#define SAMPLE_INTERVAL     500
#define ALARM_TOGGLE        250

#define LOW_THRESH_FLG      0b00000001
#define ALARM_STATE         0b00000010
#define TAKE_SAMPLE_FLG     0b00000100
bool
    bFlags;

// Variables will change:
int ledState = LOW;             // ledState used to set the LED

// Generally, you should use "unsigned long" for variables that hold time
// The value will quickly become too large for an int to store
unsigned long
    currentTime,
    last_AlarmTime,
    last_SampleTime;
    
void setup() {
  // set the digital pin as output:
  pinMode(ledPin, OUTPUT);
  pinMode(ledAlarm, OUTPUT);
  // initialize serial communications:
  Serial.begin(9600);
  while( !Serial ); //wait for console

  currentTime = millis();
  last_AlarmTime = currentTime;
  last_SampleTime = currentTime;
  bFlags = 0b00000000;
  
}
void loop() 
{
    Channel_Read();
    GeneralTimerUpdates();
    Output_Handler();

}//loop

void Channel_Read()
{
    if( !(bFlags & TAKE_SAMPLE_FLG) )
        return;        
        
    if( analogRead(analogPin) < threshold )
        bFlags |= LOW_THRESH_FLG;
    else
        bFlags &= ~LOW_THRESH_FLG;
    
    bFlags &= ~TAKE_SAMPLE_FLG;
        
}//Channel_Read

void GeneralTimerUpdates()
{
    currentTime = millis();

    //sample timer
    if( (currentTime - last_SampleTime) >= SAMPLE_INTERVAL )
    {
        bFlags |= TAKE_SAMPLE_FLG;
        last_SampleTime = currentTime;
            
    }//if

    //alarm timer
    if( (currentTime - last_AlarmTime) >= ALARM_TOGGLE )
    {
        //toggle ALARM flag in bFlags; alarm output will track it
        //if input is < threshold
        bFlags ^= ALARM_STATE;
        last_AlarmTime = currentTime;
            
    }//if
    
}//GeneralTimerUpdates

void Output_Handler()
{
    //if below threshold, alarm tracks ALARM_STATE bit
    //otherwise it's off
    //assumes HIGH turns on alarm
    digitalWrite( ledAlarm, (bFlags & LOW_THRESH_FLG) ? ((bFlags & ALARM_STATE)?HIGH:LOW):LOW );

    //if below threshold, LED is on solid
    //otherwise it's off
    //assumes HIGH turns on LED
    digitalWrite( ledPin, (bFlags & LOW_THRESH_FLG) ? HIGH:LOW );
    
}//Output_Handler

Just an evolution of your concept. Moved things around for clarity, added a couple of things. Food for thought if nothing else.

YMMV. Compiled for a MKR WiFi 1010 but not tried…

Thx Blackfin, I tried it…it just turned pin 13 HIGH.

No data in serial monitor, no pin activity for pin 6.

I’m still focused on the values change (goes below threshold (one time) then back up.

I think this is what I’m missing

To re-capture:
( analogRead(analogPin) < threshold ) //and this will only happen once to “Trip” the 6 & 13 pins HIGH, then the values will immediately rise again, but want to leave pin 6 HIGH and continue to continuously blink Pin 13

I think im going crazy. :o

6 & 13 Pins go HIGH, 6 stays high & 13 stays HIGH (((but want it to continuously blink)))

Both pins go HIGH when threshold goes below 90.

But threshold immediately goes back up so i think that’s why the blinking of 13 is not occurring.

/*
  Blink without Delay

  Turns on and off a light emitting diode (LED) connected to a digital pin,
  without using the delay() function. This means that other code can run at the
  same time without being interrupted by the LED code.

  The circuit:
  - Use the onboard LED.
  - Note: Most Arduinos have an on-board LED you can control. On the UNO, MEGA
    and ZERO it is attached to digital pin 13, on MKR1000 on pin 6. LED_BUILTIN
    is set to the correct LED pin independent of which board is used.
    If you want to know what pin the on-board LED is connected to on your
    Arduino model, check the Technical Specs of your board at:
    https://www.arduino.cc/en/Main/Products

  created 2005
  by David A. Mellis
  modified 8 Feb 2010
  by Paul Stoffregen
  modified 11 Nov 2013
  by Scott Fitzgerald
  modified 9 Jan 2017
  by Arturo Guadalupi

  This example code is in the public domain.

  http://www.arduino.cc/en/Tutorial/BlinkWithoutDelay
*/

// constants won't change. Used here to set a pin number:
const int ledPin =  LED_BUILTIN;// the number of the LED pin
const int analogPin = A0;    // pin that the Solar panel is attached to
const int threshold = 90;   // The threshold level that is between the solar value readings when the laser is in contact vs when the laser is off.
                             // change threshold value to calabrate alarm system
const int ledAlarm = 6;

// Variables will change:
int ledState = LOW;             // ledState used to set the LED

// Generally, you should use "unsigned long" for variables that hold time
// The value will quickly become too large for an int to store
unsigned long previousMillis = 0;        // will store last time LED was updated

// constants won't change:
const long interval = 1000;           // interval at which to blink (milliseconds)

void setup() {
  // set the digital pin as output:
  pinMode(ledPin, OUTPUT);
  pinMode(ledAlarm, OUTPUT);
  // initialize serial communications:
  Serial.begin(9600);
}

void loop() {
  // here is where you'd put code that needs to be running all the time.

  // check to see if it's time to blink the LED; that is, if the difference
  // between the current time and last time you blinked the LED is bigger than
  // the interval at which you want to blink the LED.


  int analogValue = analogRead(analogPin);

   if (analogValue < threshold) {
    digitalWrite(ledAlarm, HIGH);

  // if the analog value is high enough, turn on the LED(alarm):
  

  unsigned long currentMillis = millis();
 if (currentMillis - previousMillis >= interval) 
    // save the last time you blinked the LED
    previousMillis = currentMillis;

    // if the LED is off turn it on and vice-versa:
    if (ledState == LOW) {
      ledState = HIGH;
    } else 
      ledState = LOW;
    

    // set the LED with the ledState of the variable:
    {digitalWrite(ledPin, ledState);}

   
  // print the analog value:
  Serial.println(analogValue);
        // delay in between reads for stability
   }}

I just realized in my example that I made bFlags a bool instead of a byte. Try re-compiling with that fixed.

Blackfin:
I just realized in my example that I made bFlags a bool instead of a byte. Try re-compiling with that fixed.

Yes, it works now as long as the threshold is less than 90.
but it’s constantly looking…so the pins go low when value goes back up.

Perhaps there is a way once it goes low to STOP.??