simple soft-button issue.

Thanks for the pointers! I've been able to make this work. The code was refined. I did not have to take the noise into account with the switch and code I'm using (the switch is the one included on the SparkFun protoshield). The only thing that could still be integrated (noise excluded) is soft debounce, as it's now tracking changes of LOW to HIGH state. I'll have to look into it, but I don't think it would be so hard to do. I'll post an update when I do. Here is what I came up with.

int statusLED  = 13;
int flashLED   = 11;
int actionBtn  = 12;
int btnVal     = 0;
int softVal    = 0;
int lastBtnVal = HIGH;

void setup () {
  pinMode(statusLED, OUTPUT);
  digitalWrite(statusLED, HIGH);
 
  pinMode(flashLED, OUTPUT);
  pinMode(actionBtn, INPUT);
  
  beginSerial(9600); // Connect to the serial port, used for debugging
}

void loop() {
  btnVal = digitalRead(actionBtn);
  if (btnVal == LOW && lastBtnVal == HIGH) {
     lastBtnVal = LOW;
     Serial.println("Going low");
  }
  
  if (btnVal == HIGH && lastBtnVal == LOW) {
    softVal = !softVal;
    lastBtnVal = HIGH;
    Serial.println("Going high");
  }
  
  digitalWrite(flashLED, softVal);
}

Hopefully this will help others too :slight_smile: