Arduino While Loop


Posted on Feb 7, 2014

Sometimes you want everything in the program to stop while a given condition is true. You can do this using a while loop. This example shows how to use a while loop to calibrate the value of an analog sensor. In the main loop, the sketch below reads the value of a photoresistor on analog pin 0 and uses it to fade an LED on pin 9. But while a butt


Arduino While Loop
Click here to download the full size of the above Circuit.

on attached to digital pin 2 is pressed, the program runs a method called calibrate() that looks for the highest and lowest values of the analog sensor. When you release the button, the sketch continues with the main loop.




Leave Comment

characters left:

New Circuits

.

 


Popular Circuits

One-mospower-fet-analog-switch
Ultrasonic-pulsed-pest-controller
Flashing Brake Light Circuit
Battery Test Circuit Circuit
Firefly Lights Circuit
frequency counter
VHF Antenna Amplifier Circuit Using BFT66 Transistor
Middle Frequency Equalizer with Parametric Feature
Simple Code Lock Circuit
High Voltage Generator



Top