Rewrite this code for TinyOS in different way Rewrite this code for TinyOS in di
ID: 3571357 • Letter: R
Question
Rewrite this code for TinyOS in different way
Rewrite this code for TinyOS in different way #include ''Timer.h" module BlinkC @safe () {uses interface Timer as Timer();//uses interface Timer as Timer1;//uses interface Timer as Timer2; uses interface Leds; uses interface Boot:} implementation {event void Boot. booted () {call Timer0. start Pcriodic(250);//call Timerl. startPeriodic (500);//call Timer2. startPeriodic (1000);} event void Timer0. fi red () {dbg(" BlinkC", ''Timer 0 fired @ % s ", sim_time_string (int counter = 0; if (counter & 0b001) {call Leds. Led0On (); call Leds. led 1 Off (); call Leds. led2Off();} else if (counter & Ob010) {call Leds. led0Off (); call Leds. led1 On (); call Leds. led2Off();} else if (counter & Ob100) {call Leds. led0OOff (); call Leds. led 1Off(); call Leds.led2On ();} counter++;}}Explanation / Answer
#include "Timer.h"
module BlinkC @safe(){
uses interface Timer<TMilli> as Timer();
uses interface Boot;
uses interface Leds;
}
implementation{
event void Boot.booted(){
int time_p=250;
call Timer0.startPeriodic(time_p);
}
event void Timer0.fired(){
dgb("BlinkC","Timer 0 fired @ %s ",sim_time_string);
int measure=0;
if(measure)
if(0b001){
call Leds.lead0On();
call Leds.led1Off();
call Leds.led2Off();
}
else if(measure)
if(0b010){
call Leds.lead0Off();
call Leds.led1On();
call Leds.led2Off();
}
else if(measure)
if(0b100){
call Leds.lead0Off();
call Leds.led1Off();
call Leds.led2On();
}
measure++;
} }
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.