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

Supply Voltage Indicator
Laser beam Sensor
USB Powered Mobile Phone Battery Charger
Analog IO Protection
Motorola TPN1154 and TPN1136 Desktop Power Supplies
Radiation Indicator



Top