B. The Arduino Sketch
The Arduino platform was built with the beginner in mind. Compared to a normal C program
the Arduino IDE hides a few things from you to simplify the setup. First of all you do not have
to create a makefile to build your code into an executable binary. The Arduino IDE also
includes a default header file for you:
#include
"Arduino.h". This contains all definitions
needed for a regular Arduino program.
Another important change compared to a regular C/C++ program are the two default
functions
setup()
and loop(). The first will be only called once during startup, while the
loop()
method will be called repeatedly. On a normal Arduino hardware (ATmega chip) you can
theoretically write code and never leave the
loop()
method again. The ESP8266 is a bit
different here. If your operations run for too much time a so-called watchdog will reset the
ESP8266. You can prevent this by allowing the controller to do important operations while
you are still in the main loop. Calling
yield()
or
delay(ms)
will do this.
Need help?
Do you have a question about the ESP8266 and is the answer not in the manual?
Questions and answers