120 likes | 463 Views
HelloWorld. By using LED & Timer components, we will display “helloworld” in a manner of Morse code. Morse Code & LED. Morse Code. Morse code Using Dot and dash, 3 dots distance for distinguish character and symbol Following table shows morse code for alphabet. HelloWorld Example.
E N D
HelloWorld By using LED & Timer components, we will display “helloworld” in a manner of Morse code.
Morse Code • Morse code • Using Dot and dash, 3 dots distance for distinguish character and symbol • Following table shows morse code for alphabet
HelloWorld Example • HelloWorld source location • c:\Programfiles\UCB\cygwin\opt\tinyos‐1.x\contrib\zigbex\ helloworld • HelloWorld.nc &HelloWorldM.nc
HelloWorld.nc • HelloWorld.nc • Configuration file configuration HelloWorld { } implementation { components Main, HelloWorldM, TimerC, LedsC; Main.StdControl ‐> HelloWorldM; Main.StdControl ‐> TimerC; HelloWorldM.Timer ‐> TimerC.Timer[unique("Timer") ]; HelloWorldM.Leds ‐> LedsC; }
HelloWorldM.nc • HelloWorldM.nc (1) module HelloWorldM { provides { interface StdControl; } uses { interface Timer; interface Leds; } } implementation { command result_t StdControl.init() { call Leds.init(); call Leds.redOff(); call Leds.yellowOff(); call Leds.greenOff(); return SUCCESS; } command result_t StdControl.start() { return call Timer.start(…); }
HelloWorldM.nc • HelloWorldM.nc (2) command result_t StdControl.stop() { return call Timer.stop(); } event result_t Timer.fired() { static char *morse = ".... . .‐.. .‐.. ‐‐‐ ‐‐..‐‐ " ".‐‐ ‐‐‐ .‐. .‐.. ‐.. "; static char *current; if( !current ) current = morse; switch( *current ) { case ' ': /* pause: off for two units */ call Timer.start(TIMER_ONE_SHOT, 2 * MORSE_UNIT); current++; break; case '.': /* dot: on for one unit, off for one unit */ … if( !*current ) current = morse; return SUCCESS; } }
HelloWorld lab. 1 • Cygwin starts and move directory as follows: • make zigbex cd /opt/tinyos‐1.x/contrib/zigbex cd helloworld
HelloWorld lab. 2 • ZigbeX Download • Run AVR studio at Windows • Tolol->auto connect-> browse main.hex located at • c:\Programfiles\UCB\cygwin\opt\tinyos‐1.x\contrib\zigbex\HelloWorld\ build\zigbex
HelloWorld result • result • Check the LED