タイマー割込みのサンプルプログラム

Dependencies:   mbed

main.cpp

Committer:
GGU
Date:
2019-07-29
Revision:
0:53a95ad717d7

File content as of revision 0:53a95ad717d7:

#include "mbed.h"

//Ticker flipper;
DigitalOut led1(A0);
DigitalOut led2(LED1);

/*void flip(){
    led2=!led2;
    flipper.attach(&flip,2.0);
}

int main(){
    led2 = 1;
    flipper.attach(&flip,2.0);
    while(1){
        led1 = !led1;
        wait(0.2);
    }
}*/


Ticker flipper;

void flip(){
    led2=!led2; //LED is OFF
    flipper.attach(&flip,2.0);
}

int main(){
    led2 = 1;   //LED2 is ON
    flipper.attach(&flip,2.0); // the address of the function to be attached (flip) and the interval (2 seconds)
    while(1){
        led1 = !led1;   //LED1は0.2sずつ点滅
        wait(0.2);
    }
}