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(A5); //スイッチ1入力設定 00006 AnalogIn sw2(A4); //スイッチ2入力設定 00007 00008 int main() 00009 { 00010 char c = 0; //SWのカウント数 00011 00012 lcd.cls(); //画面をリセット 00013 00014 lcd.locate(0,0); //表示座標 00015 lcd.puts("push switch"); //表示文字 00016 00017 lcd.locate(0,1); //表示座標 00018 lcd.puts("00"); //表示文字 00019 00020 while(1) //無限ループ 00021 { 00022 if(sw1 == 1) //SWが押されると{}内を実行 00023 { 00024 wait(0.25); //チャタリング除去(スイッチの振動で入力が1回以上入るのを防ぐため) 00025 c++; //カウント値に1足す 00026 00027 if(c > 99) //カウント値が99になったとき{}内実行 00028 { 00029 c = 0; //カウント値初期化 00030 } 00031 00032 lcd.locate(0,1); //表示座標 00033 lcd.putc((c / 10) % 10 + '0'); //表示文字 00034 lcd.putc((c / 1) % 10 + '0'); //表示文字 00035 } 00036 } 00037 }
Generated on Tue Jul 26 2022 01:51:24 by
1.7.2