PwmBeepライブラリのデモプログラムです。

Dependencies:   mbed PwmBeep

Files at this revision

API Documentation at this revision

Comitter:
hmizuno
Date:
Fri May 22 08:40:07 2020 +0000
Commit message:
first release

Changed in this revision

PwmBeep.lib Show annotated file Show diff for this revision Revisions of this file
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 b9598f69d256 PwmBeep.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/PwmBeep.lib	Fri May 22 08:40:07 2020 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/hmizuno/code/PwmBeep/#c6220b0517a5
diff -r 000000000000 -r b9598f69d256 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri May 22 08:40:07 2020 +0000
@@ -0,0 +1,36 @@
+#include "mbed.h"
+#include "PwmBeep.h"
+
+//ポートには数キロΩの抵抗を通して圧電スピーカーを接続してください。
+PwmBeep beep(p22);
+
+int main() {
+    while(1) {
+        beep.turnOn();
+        wait(1.0);
+        beep.turnOff();
+        wait(1.0);
+        
+        beep.setFreq(1250);
+        
+        //別の処理が進む
+        beep.NshotOn(2, 0.4, 0.1);
+        wait(0.2);
+        
+        beep.setFreq(1500); //NshotOnの途中で実行される
+        wait(1.0);
+        
+        beep.setFreq(1250);
+        
+        //別の処理が止まる
+        beep.NshotOnwithWait(2, 0.4, 0.1); 
+        wait(0.2);
+        
+        beep.setFreq(2000); //NshotOnwithWait終了後実行される
+        
+        beep.oneshotOn(0.1);
+        wait(0.2);
+        
+        beep.setFreq(1000);
+    }
+}
diff -r 000000000000 -r b9598f69d256 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Fri May 22 08:40:07 2020 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400
\ No newline at end of file