Description
After the setup() function completes the initialization of the program, the loop() function will run, the code in the loop() body will run repeatedly. By using the loop() function, you can control the Arduino board and allowing the Arduino to react according to your program.
Example Code
int buttonPin = 3;
// define initializes serial and the button pin
void setup() {
Serial.begin(9600);
pinMode(buttonPin, INPUT);
}// loop checks the button pin each time,
// and will send serial if it is pressedvoid loop() {
if (digitalRead(buttonPin) == HIGH) {
Serial.write(‘H’);
}
else {
Serial.write(‘L’);
}// pause for 1 second
delay(1000);
}



