user67141: I would like to exit a particular loop if the state of an input changes from LOW to HIGH. This is the current loop:
void brakeFade() {
pixels.clear();
pixels.setBrightness(255);
pixels.fill(16711680, 0, 0);

for(int i=255; i>=10; i-=1) {
  pixels.setBrightness(i);
  pixels.show();
  delay(5);
  }
for(int j=10; j<=255; j+=1) {
  pixels.setBrightness(j);
  pixels.show();
  delay(5);

}
}
I need that loop to exit if
(digitalRead(brakeFeed) == LOW)

Changes to HIGH during the loop.

user67141: figured it out:
void brakeFade2() {
pixels.clear();
pixels.setBrightness(255);
pixels.fill(16711680, 0, 0);

for(int i=255; i>=10; i-=1) {
  if (digitalRead(brakeFeed) == LOW){
  pixels.setBrightness(i);
  pixels.show();
  delay(5);
  }
  else {
    break;
  }
}
for(int j=10; j<=255; j+=1) {
  if (digitalRead(brakeFeed) == LOW){
  pixels.setBrightness(j);
  pixels.show();
  delay(5);
  }
  else {
    break;
  }
  }

}

67141: <p>I would like to exit a particular loop if the state of an input changes from LOW to HIGH. This is the current loop:</p>
<pre><code>void brakeFade() {
pixels.clear();
pixels.setBrightness(255);
pixels.fill(16711680, 0, 0);

for(int i=255; i&gt;=10; i-=1) {
  pixels.setBrightness(i);
  pixels.show();
  delay(5);
  }
for(int j=10; j&lt;=255; j+=1) {
  pixels.setBrightness(j);
  pixels.show();
  delay(5);
</code></pre>
<p>}
}</p>
<p>I need that loop to exit if</p>
<pre><code>(digitalRead(brakeFeed) == LOW)
</code></pre>
<p>Changes to <strong>HIGH</strong> during the loop.</p>
 67141: <p>figured it out:</p>
<pre><code>void brakeFade2() {
pixels.clear();
pixels.setBrightness(255);
pixels.fill(16711680, 0, 0);

for(int i=255; i&gt;=10; i-=1) {
  if (digitalRead(brakeFeed) == LOW){
  pixels.setBrightness(i);
  pixels.show();
  delay(5);
  }
  else {
    break;
  }
}
for(int j=10; j&lt;=255; j+=1) {
  if (digitalRead(brakeFeed) == LOW){
  pixels.setBrightness(j);
  pixels.show();
  delay(5);
  }
  else {
    break;
  }
  }
</code></pre>
<p>}</p>
