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

Triangle-square-wave-generator
Fixed-Current Regulator
How to implement a soft power switch controllable by microcontroller
laser diode driver circuit
one second audible clock
Voltage to Current Convertor using LM723 Project PCB
Dual Axis Stepper Motor Controller
A Regenerative Receiver with AGC for 80 and 40 Meters
Car Headlights Timer Circuit Schematic
Electronic Torricelli Barometer
An Add-On Current Limiter For Your Power Supply



Top