Basic Tutorial for programming in #Contiki Operating System for #IoT| PART 5


Part 1 in this series can be found here.
Part 2 can be found here.
Part 3 can be found here.
Part 4 can be found here.






Let see how to use a timer to display a multiplication table of 5 on the serial port.
#include "contiki.h"
#include < stdio.h >
PROCESS(hello, "Table of 5");
AUTOSTART_PROCESSES(&hello);
PROCESS_THREAD(hello, ev, data)
{
static struct etimer  timer;
static int i;
PROCESS_BEGIN();
while(1)
{
etimer_set(&timer, CLOCK_CONF_SECOND);
PROCESS_WAIT_EVENT_UNTIL(ev==PROCESS_EVENT_TIMER);
for(i=1; i < 11; i++)
printf("5 x %d   =  %d\n", i, i*5);
}
PROCESS_END();
}


I deliberately didn't include any comments here. This is where you should stop and write your own comments based on what you understood. If you think the code above doesn't make sense, then I believe you went too fast. Upon successful compilation, the output should continuously scroll. Something similar to this should be displayed:
comments