Computer/Tiny OS
[Tiny os] 5진 카운트 [타이머 한개]
nsakura
2010. 12. 2. 09:36
8진 카운트에서 하나만 바꿔주면.. 5진카운터가 되죠. [타이머 하나]
module BlinkTimerM {
uses {
interface Boot;
interface Timer<TMilli>;
interface Leds;
}
}
implementation {
ncnt=0;
event void Boot.booted() {
call Timer.startPeriodic(1000);
}
event void Timer.fired() {
call Leds.led0Off();
call Leds.led1Off();
call Leds.led2Off();
if(ncnt>3){
call Leds.led0On();
}
if(ncnt%4>1){
call Leds.led1On();
}
if(ncnt%2>0){
call Leds.led2On();
}
ncnt++;
if(ncnt==5){
ncnt=0;
}
}
}
R | G | Y | ncnt | G mod | Y mod |
0 | 0 | 0 | 0 | 0 | 0 |
0 | 0 | 1 | 1 | 1 | 1 |
0 | 1 | 0 | 2 | 2 | 0 |
0 | 1 | 1 | 3 | 3 | 1 |
1 | 0 | 0 | 4 | 0 | 0 |
5->0 |