This is the basic ARTe example. The application is in charge of making the embedded LED blinking every 100 ms and send the string "Hello ARTe" on the serial line each second
The selected example consists in a simple multi-rate LED blinking application. In this example, the application is in charge of making three different LEDs blinking with different periods, equal to 3, 7, and 11 seconds, respectively.
Listing: Example of multi-rate blinking leds sketches written using classic Arduino (a) and ARTE (b).
Listing (a) shows the considered example implemented with the classical Arduino programming model. The single Arduino loop() contains a delay instruction that is responsible for defining the time granularity of the loop. The argument passed to the delay function must be equal to the greatest common divisor (GCD) of the blinking periods (in this case 1 second). A variable count is used to keep track of the current multiple of the time granularity to determine which led has to blink.
On the other side, Listing (b) shows the same program formulated using the ARTE programming model. Using the proposed approach is it possible to specify three different loops, one for each led. The parameter indicated in the brackets of the loop is the period (in milliseconds) at which it has to be executed. Although such a simple example can still be easily handled with the original Arduino framework, the situation can get worse with more complex applications, requiring a much higher programming effort to emulate a multithread behavior.