Tuesday, June 11, 2013

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");
PROCESS_THREAD(hello, ev, data)
static struct etimer  timer;
static int i;
etimer_set(&timer, CLOCK_CONF_SECOND);
for(i=1; i < 11; i++)
printf("5 x %d   =  %d\n", i, i*5);

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: