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); //SW入力設定 00006 AnalogIn sw2(A4); //SW入力設定 00007 DigitalOut out4(D4); //LED出力設定 00008 int main() 00009 { 00010 int a = 0; //関数aを定義 00011 int y = 0; 00012 00013 lcd.locate(a,y); //表示座標 00014 lcd.puts("@"); //文字表示 00015 00016 while(1) //無限ループ 00017 { 00018 if(sw1 == 1) //swが押されたら{}内実行 00019 { 00020 if(a <= 16 && y == 0) 00021 { 00022 a++; 00023 wait(0.5); 00024 } 00025 00026 if(a >= 0 && y == 1) 00027 { 00028 a--; 00029 wait(0.5); 00030 } 00031 00032 if(y == 0 && a >= 16) 00033 { 00034 a = 15; 00035 y = 1; 00036 } 00037 00038 if(y == 1 && a < 0) 00039 { 00040 a = 0; 00041 y = 0; 00042 } 00043 lcd.cls(); 00044 } 00045 00046 if(sw2 == 1) 00047 { 00048 if(a <= 16 && y == 0) 00049 { 00050 a--; 00051 wait(0.5); 00052 } 00053 00054 if(a >= 0 && y == 1) 00055 { 00056 a++; 00057 wait(0.5); 00058 } 00059 00060 if(y == 0 && a < 0) 00061 { 00062 00063 a = 0; 00064 y = 1; 00065 } 00066 if(y == 1 && a >= 16) 00067 { 00068 a = 15; 00069 y = 0; 00070 } 00071 lcd.cls(); 00072 } 00073 lcd.locate(a,y); //表示座標 00074 lcd.puts("@"); //文字表示 00075 } 00076 }
Generated on Sat Aug 27 2022 18:15:02 by
1.7.2