Kenji Arai / Mbed OS Check_Piezo_Buzzer

Dependencies:   Piezo_Buzzer

Files at this revision

API Documentation at this revision

Comitter:
kenjiArai
Date:
Sat Mar 03 02:02:57 2018 +0000
Commit message:
Checking program for Piezo_Buzzer (Interrupt driven piezo buzzer control library)

Changed in this revision

Piezo_Buzzer.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-os.lib Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Piezo_Buzzer.lib	Sat Mar 03 02:02:57 2018 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/kenjiArai/code/Piezo_Buzzer/#5cf10634ae7b
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sat Mar 03 02:02:57 2018 +0000
@@ -0,0 +1,45 @@
+/*
+ * Mbed Application program
+ *  check Piezo Buzzer function
+ *
+ * Copyright (c) 2018 Kenji Arai / JH1PJL
+ *  http://www.page.sannet.ne.jp/kenjia/index.html
+ *  http://mbed.org/users/kenjiArai/
+ *      Modify:     Feburary  28th, 2018
+ *      Revised:    March      3rd, 2018
+ */
+
+//  Include --------------------------------------------------------------------
+#include "mbed.h"
+#include "piezo_bz.h"
+
+//  Definition -----------------------------------------------------------------
+
+//  Object ---------------------------------------------------------------------
+Serial      pc(USBTX, USBRX);
+//PIEZO_BZ    bz(D8, 500, 500);
+PIEZO_BZ    bz(D8, 500, CONTINUOUS_MODE);   // 500Hz Continuous Mode
+
+//  RAM ------------------------------------------------------------------------
+
+//  ROM / Constant data --------------------------------------------------------
+
+//  Function prototypes --------------------------------------------------------
+
+//------------------------------------------------------------------------------
+//  Control Program
+//------------------------------------------------------------------------------
+int main()
+{
+    while (true) {
+        for (uint32_t i = 1; i < 110; i++) {
+            uint32_t freq = (500 * i) /10;
+            bz.start();
+            wait(2.0f);
+            bz.stop();
+            wait(0.1f);
+            bz.change_frequency(freq);
+            pc.printf("Freq= %4d [Hz]\r\n", freq);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-os.lib	Sat Mar 03 02:02:57 2018 +0000
@@ -0,0 +1,1 @@
+https://github.com/ARMmbed/mbed-os/#91e6db1ea251ffcc973001ed90477f42fdca5751