T00221592 Winter Lab 1 Speaker experiment
Revision 0:f9e72987fb27, committed 2021-12-21
- Comitter:
- t00221592
- Date:
- Tue Dec 21 10:06:10 2021 +0000
- Commit message:
- T00221592 Winter Lab 1 Speaker experiment
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 |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Tue Dec 21 10:06:10 2021 +0000
@@ -0,0 +1,17 @@
+#include "mbed.h"
+DigitalIn fire(p14);
+PwmOut spkr(p26);
+AnalogIn pot1(p19);
+float start=2000.0, end=10000.0, step=100;
+int main() {
+ while (1) {
+ for (float i=start; i<end; i+=step) {
+ spkr.period(1.0/i);
+ spkr=0.5;
+ wait(0.1);
+ }
+ spkr=0.0;
+ while(pot1.read() < 0.5) {} // this uses the pot to control the program
+ start=10000.0, end=15000.0, step=100;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Tue Dec 21 10:06:10 2021 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400 \ No newline at end of file