Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp
00001 #include "mbed.h" 00002 #include "TextLCD.h" 00003 00004 TextLCD lcd(D8,D10,D11,D12,D13,D14); // rs, e, d4, d5, d6, d7) //LCD出力設定 00005 AnalogIn sw1(A4); //SW入力設定 00006 00007 int main() 00008 { 00009 int c = 0; //int型変数定義 00010 int ms = 0; //int型変数定義 00011 int s = 0; //int型変数定義 00012 int m = 0; //int型変数定義 00013 00014 lcd.cls(); //LCD表示初期化 00015 while(1) //無限ループ 00016 { 00017 if(sw1 == 1) //SWが押されたとき{}内実行 00018 { 00019 wait(0.25); //0.25秒待つ 00020 c++; //cに1足す 00021 } 00022 if(c == 1) //cが1の時{}内実行 00023 { 00024 ms++; //ms(1/10秒)に1足す 00025 wait(0.0073); //0.0073秒待つ 00026 if(ms == 99) //msが99になった時{}内実行 00027 { 00028 ms = 0; //msを初期化 00029 s++; //s(秒)に1足す 00030 if(s == 60) //sが60になった時{}内実行 00031 { 00032 s = 0; //sを初期化 00033 m++; //mに1足す 00034 } 00035 } 00036 } 00037 if(c >= 3) //cが3以上になった時{}内実行 00038 { 00039 ms = 0; //ms初期化 00040 s = 0; //s初期化 00041 m = 0; //m初期化 00042 c = 0; //c初期化 00043 } 00044 00045 lcd.locate(0,0); //表示座標 00046 lcd.putc((m/10) % 10 + '0'); //LCDにmに格納された変数の10の位を表示 00047 lcd.putc((m/1) % 10 + '0'); //LCDにmに格納された変数の1の位を表示 00048 lcd.puts(":"); //時刻表示に使われる:コロンを表示 00049 00050 lcd.locate(3,0); //表示座標 00051 lcd.putc((s/10) % 10 + '0'); //LCDにsに格納された変数の10の位を表示 00052 lcd.putc((s/1) % 10 + '0'); //LCDにsに格納された変数の1の位を表示 00053 lcd.puts(":"); //時刻表示に使われる:コロンを表示 00054 00055 lcd.locate(6,0); //表示座標 00056 lcd.putc((ms/10) % 10 + '0'); //LCDにmsに格納された変数の10の位を表示 00057 lcd.putc((ms/1) % 10 + '0'); //LCDにmsに格納された変数の1の位を表示 00058 } 00059 }
Generated on Tue Jul 12 2022 22:12:28 by
1.7.2