user52264: I have an analog light sensor working on my Micro Pro Leonardo board. I want to reach a part of my code which include keyboard presses where it monitors to see when an LED flashes and then continues the code from there.
Could someone give me a code example of how I can do that?
Currently I'd have something like....
  Keyboard.write(KEY_RETURN);
  delay(800);
  Keyboard.write(KEY_TAB);
  delay(150);
  Keyboard.write(KEY_TAB);
  delay(150);
  Keyboard.write(' ');
    }

//Code here to wait until LED flashes, registers as 30 or less on the light sensor. Then carry on with code below once this happens

  BootKeyboard.press(KEY_LEFT_GUI);
  BootKeyboard.press('r');
  delay(40000);
  BootKeyboard.releaseAll();

etc
I know the light sensor is AnalogValue = analogRead(A0); and I assume it's some kind of "If" statement which loops until the value because less than what is defined but have no idea how this would be written.

user42539: One method:
while (analogRead(A0) < setting){
// sit in this loop taking readings until get one that is >= to setting
}

52264: <p>I have an analog light sensor working on my Micro Pro Leonardo board. I want to reach a part of my code which include keyboard presses where it monitors to see when an LED flashes and then continues the code from there.</p>

<p>Could someone give me a code example of how I can do that?</p>

<p>Currently I'd have something like....</p>

<pre><code>  Keyboard.write(KEY_RETURN);
  delay(800);
  Keyboard.write(KEY_TAB);
  delay(150);
  Keyboard.write(KEY_TAB);
  delay(150);
  Keyboard.write(' ');
    }

//Code here to wait until LED flashes, registers as 30 or less on the light sensor. Then carry on with code below once this happens

  BootKeyboard.press(KEY_LEFT_GUI);
  BootKeyboard.press('r');
  delay(40000);
  BootKeyboard.releaseAll();
</code></pre>

<p>etc</p>

<p>I know the light sensor is <code>AnalogValue = analogRead(A0);</code> and I assume it's some kind of "If" statement which loops until the value because less than what is defined but have no idea how this would be written.</p>
 42539: <p>One method:</p>

<p>while (analogRead(A0) &lt; setting){
// sit in this loop taking readings until get one that is >= to setting
}</p>
