目的
簡易な時間づくり
例題をほぼそのまま使用
SER_time_test1_767_1
#include "mbed.h"
DigitalOut led(LED1);
Serial pc(SERIAL_TX, SERIAL_RX);
Ticker flipper;
time_t seconds = 0 + (60 * 60 * 9); // JST
void flip() {
led = !led;
seconds++;
}
int main()
{
flipper.attach(&flip, 1.0); // the address of the function to be attached (flip) and the interval (1 seconds)
pc.printf("\r\n<START>\r\n");
struct tm *t;
while(1) {
t = localtime(&seconds);
pc.printf("%04d/%02d/%02d %02d:%02d:%02d",
t->tm_year + 1900, t->tm_mon + 1, t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec);
pc.printf("\r\n");
wait(1.0);
}
}