Re: How to loop once?

make a flag

int trigger = 0

if (trigger == 0)
{
if (valS == HIGH) { // waits for switch to be pressed, and then:
trigger = 1;
etc
}

or...

while(digitalRead(inputpin) == LOW){}

:wink:

He already told you the answer.

An example using your code:

int trigger = 0; //globally define the trigger

void loop()
{
valF = analogRead(forcePin); // read value of force sensor
valS = digitalRead(switchPin); // read value of switch

if (valF>=thresHold && trigger == 0) { // waits for force sensor to equal or pass pressure threshold 
  //and makes sure the button hasn't been pressed before
  trigger = 1; //signal that button has been pressed before to prevent re-triggering
  delay(1000);
  digitalWrite(RedPin, LOW);  // turns on red LED
  delay(1000);  // waits one seconds
  digitalWrite(RedPin, HIGH);  // turns on red LED
  delay(500);  // waits half second
  }

explain

run once and quit does not have much to do with loop, and I am not sure whats happening

do you want it to push button once, then loop twice and not again or what

(confused, but not trying to alienate you)

I still don't know exactly how you want to do this, but I have an idea.

int valFenabled = 1;
int valSenabled = 0;

void loop()
{
valF = analogRead(forcePin); // read value of force sensor
valS = digitalRead(switchPin); // read value of switch

if (valF>=thresHold && valFenabled) { // waits for force sensor to equal or pass pressure threshold
  //and makes sure the button hasn't been pressed before
  valFenabled = 0; //signal that button has been pressed before to prevent re-triggering
  delay(1000);
  digitalWrite(RedPin, LOW);  // turns on red LED
  delay(1000);  // waits one seconds
  digitalWrite(RedPin, HIGH);  // turns on red LED
  delay(500);  // waits half second
  valSenabled = 1;
  }

if (valS>=thresHold && valSenabled) { // waits for force sensor to equal or pass pressure threshold
  //and makes sure the button hasn't been pressed before
  valSenabled = 0; //signal that button has been pressed before to prevent re-triggering
  delay(1000);
  digitalWrite(RedPin, LOW);  // turns on red LED
  delay(1000);  // waits one seconds
  digitalWrite(RedPin, HIGH);  // turns on red LED
  delay(500);  // waits half second
  valFenabled = 1;
  }

Each button will enable the other after doing whatever... Did you write the other code or look at it from examples?

I think the original poster has taken his ball home in a huff. :cry:

Hmm, he actually disappeared...

Nothing wrong at all with asking for help, but at least make an attempt to learn what is going on and try a solution yourself.