1. Install TinyOS. Please refer http://www.tinyos.net/tinyos-2.x/doc/html/install-tinyos.html
2. Make sure you have the correct version of Java on your machine. The default Java on your machine may confilct with the required one.
3. mkdir HelloWorld
4. HelloWorldAppC.nc file:
configuration HelloWorldAppC {
}
implementation {
components HelloWorldC;
components MainC,LedsC;
components new TimerMilliC() as Timer0;
HelloWorldC.Boot-> MainC.Boot;
HelloWorldC.Leds-> LedsC;
HelloWorldC.Timer0->Timer0;
}
5. HelloWorldC.nc file:
module HelloWorldC{
uses{
interface Boot;
interface Leds;
interface Timer
}
}
implementation{
uint16_t count = 0;
event void Boot.booted()
{
call Timer0.startPeriodic(500);
}
event void Timer0.fired()
{
count++;
if (count & 0x0004)
call Leds.led2On();
else
call Leds.led2Off();
if (count & 0x0002)
call Leds.led1On();
else
call Leds.led1Off();
if (count & 0x0001)
call Leds.led0On();
else
call Leds.led0Off();
}
}
6. The Makefile:
COMPONENT=HelloWorldAppC
include $(MAKERULES)
7. So, now you have the HelloWorldAppC.nc, HelloWorldC.nc and Makefile, 3 files in your folder.
8. compile the code: make telosb or make micaz
9. If no error messages, then upload the binary to the mote:
make telosb reinstall
10. Now, you should see the mote saying "HelloWorld" by blinking the 3 Leds.
That is it. Enjoy your TinyOS.
1 comment:
Ya good, works correctly...
Post a Comment