
Appendix A. MQTT and devices 195
In general, the Arduino code runs such that the setup() is run once and only once. Whereas
the loop() function runs all the time unless the reset button on the board is pressed. When
reset is pressed, the code execution begins again with setup() followed by looping the loop()
function. To run the code, it is first compiled in the IDE and then is uploaded to the board. The
upload causes a reset automatically, and the execution begins as described before.
In Example A-1, the LED connected to pin 13 is first designated as an OUTPUT pin. Then, in
the loop() function, the LED is turned on using the built-in digitalWri ...