Edited at

【メモ】mbed thread

More than 1 year has passed since last update.


main.cpp

#include "mbed.h"


DigitalIn button(USER_BUTTON);
DigitalOut led(LED1);
Thread thread1;

void function1(){
for(int i=0;i < 5;i++){
led = !led;
wait(1);
}
thread1.terminate();
}

int main(){
int b;
button.mode(PullUp);
while(1){
b=button;
if(!b){
thread1.start(function1);
while(b == 0){
b=button;
}
}
}
}