loop()
Description
After creating a setup() function, which initializes and sets the initial values, the loop() function does precisely what its name suggests, and loops consecutively, allowing your program to change and respond. Use it to actively control the Arduino board.
Example Code
void setup() {
// put your setup code here, to executed once:
Serial.begin(9600);
Serial.println("This is setup code");
}
void loop() {
// put your main code here, to run repeatedly:
Serial.println("This is loop code");
delay(1000);
}
The output on Serial Monitor:
COM6
This is setup code
This is loop code
This is loop code
This is loop code
This is loop code
This is loop code
This is loop code
This is loop code
Autoscroll
Clear output
9600 baud
Newline
See Also
- Language : setup()
- Tutorial : Arduino - Code Structure
※ ARDUINO BUY RECOMMENDATION
Arduino UNO R3 | |
Arduino Starter Kit |
Disclosure: Some links in this section are Amazon affiliate links. If you make a purchase through these links, we may earn a commission at no extra cost to you.
Additionally, some links direct to products from our own brand, DIYables.
Additionally, some links direct to products from our own brand, DIYables.