Makoto Kobayashi
/
test_buzzer
buzzer tset
Revision 0:3ff0d44c36b6, committed 2014-10-20
- Comitter:
- neoqased
- Date:
- Mon Oct 20 11:12:50 2014 +0000
- Commit message:
- buzzer test
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
diff -r 000000000000 -r 3ff0d44c36b6 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Mon Oct 20 11:12:50 2014 +0000 @@ -0,0 +1,123 @@ +#include "mbed.h" + +DigitalOut buzzer(p18); //電子ブザー用デジタル出力 + +int Buzzer(int buzvar){ //電子ブザーを鳴らす関数 + switch (buzvar){ + /**************エラーを知らせるbeep**************/ + case -1: //error * - - - - + buzzer = 1; wait(0.1); buzzer = 0; wait(0.1); + buzzer = 1; wait(0.3); buzzer = 0; wait(0.3); + buzzer = 1; wait(0.3); buzzer = 0; wait(0.3); + buzzer = 1; wait(0.3); buzzer = 0; wait(0.3); + buzzer = 1; wait(0.3); buzzer = 0; wait(0.3); + break; + /**************エラーここまで**************/ + case 0: //サウンドなし + buzzer = 0; + break; + /**************状態を知らせるためのbeep**************/ + case 1: // *(短) + buzzer = 1; + wait(0.1); + buzzer = 0; + break; + case 2: // * * + buzzer = 1; + wait(0.1); + buzzer = 0; + wait(0.05); + buzzer = 1; + wait(0.1); + buzzer = 0; + break; + case 3: // -(長) + buzzer = 1; + wait(0.3); + buzzer = 0; + break; + case 4: // - - + buzzer = 1; + wait(0.3); + buzzer = 0; + wait(0.3); + buzzer = 1; + wait(0.3); + buzzer = 0; + break; + case 5: // --- + buzzer = 1; + wait(0.9); + buzzer = 0; + break; + case 6: // * * * * * * * * * * + for(int i = 0; i < 3; i++){ + buzzer = 1; + wait(0.1); + buzzer = 0; + wait(0.1); + buzzer = 1; + wait(0.1); + buzzer = 0; + wait(0.1); + buzzer = 1; + wait(0.1); + buzzer = 0; + wait(0.3); + } + buzzer = 1; + wait(0.1); + buzzer = 0; + break; + case 7: // **-* ** -* ** *** **** "finish" + buzzer = 1; wait(0.1); buzzer = 0; wait(0.1); + buzzer = 1; wait(0.1); buzzer = 0; wait(0.1); + buzzer = 1; wait(0.3); buzzer = 0; wait(0.1); + buzzer = 1; wait(0.1); buzzer = 0; wait(0.1); + wait(0.2); + buzzer = 1; wait(0.1); buzzer = 0; wait(0.1); + buzzer = 1; wait(0.1); buzzer = 0; wait(0.1); + wait(0.2); + buzzer = 1; wait(0.3); buzzer = 0; wait(0.1); + buzzer = 1; wait(0.1); buzzer = 0; wait(0.1); + wait(0.2); + buzzer = 1; wait(0.1); buzzer = 0; wait(0.1); + buzzer = 1; wait(0.1); buzzer = 0; wait(0.1); + wait(0.2); + buzzer = 1; wait(0.1); buzzer = 0; wait(0.1); + buzzer = 1; wait(0.1); buzzer = 0; wait(0.1); + buzzer = 1; wait(0.1); buzzer = 0; wait(0.1); + wait(0.2); + buzzer = 1; wait(0.1); buzzer = 0; wait(0.1); + buzzer = 1; wait(0.1); buzzer = 0; wait(0.1); + buzzer = 1; wait(0.1); buzzer = 0; wait(0.1); + buzzer = 1; wait(0.1); buzzer = 0; + break; + case 8: // *-*** -*- --* "オワリ" + buzzer = 1; wait(0.1); buzzer = 0; wait(0.1); + buzzer = 1; wait(0.3); buzzer = 0; wait(0.1); + buzzer = 1; wait(0.1); buzzer = 0; wait(0.1); + buzzer = 1; wait(0.1); buzzer = 0; wait(0.1); + buzzer = 1; wait(0.1); buzzer = 0; wait(0.1); + wait(0.2); + buzzer = 1; wait(0.3); buzzer = 0; wait(0.1); + buzzer = 1; wait(0.1); buzzer = 0; wait(0.1); + buzzer = 1; wait(0.3); buzzer = 0; wait(0.1); + wait(0.2); + buzzer = 1; wait(0.3); buzzer = 0; wait(0.1); + buzzer = 1; wait(0.3); buzzer = 0; wait(0.1); + buzzer = 1; wait(0.1); buzzer = 0; + break; + /**************状態を知らせるためのbeepここまで**************/ + default: //no sound + buzzer = 0; + break; + } + return 0; +} + + +int main() { + int buzvar = 6; + Buzzer(buzvar); +}
diff -r 000000000000 -r 3ff0d44c36b6 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Mon Oct 20 11:12:50 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/9327015d4013 \ No newline at end of file