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@0:f9e72987fb27, 2021-12-21 (annotated)
- Committer:
- t00221592
- Date:
- Tue Dec 21 10:06:10 2021 +0000
- Revision:
- 0:f9e72987fb27
T00221592 Winter Lab 1 Speaker experiment
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| t00221592 | 0:f9e72987fb27 | 1 | #include "mbed.h" |
| t00221592 | 0:f9e72987fb27 | 2 | DigitalIn fire(p14); |
| t00221592 | 0:f9e72987fb27 | 3 | PwmOut spkr(p26); |
| t00221592 | 0:f9e72987fb27 | 4 | AnalogIn pot1(p19); |
| t00221592 | 0:f9e72987fb27 | 5 | float start=2000.0, end=10000.0, step=100; |
| t00221592 | 0:f9e72987fb27 | 6 | int main() { |
| t00221592 | 0:f9e72987fb27 | 7 | while (1) { |
| t00221592 | 0:f9e72987fb27 | 8 | for (float i=start; i<end; i+=step) { |
| t00221592 | 0:f9e72987fb27 | 9 | spkr.period(1.0/i); |
| t00221592 | 0:f9e72987fb27 | 10 | spkr=0.5; |
| t00221592 | 0:f9e72987fb27 | 11 | wait(0.1); |
| t00221592 | 0:f9e72987fb27 | 12 | } |
| t00221592 | 0:f9e72987fb27 | 13 | spkr=0.0; |
| t00221592 | 0:f9e72987fb27 | 14 | while(pot1.read() < 0.5) {} // this uses the pot to control the program |
| t00221592 | 0:f9e72987fb27 | 15 | start=10000.0, end=15000.0, step=100; |
| t00221592 | 0:f9e72987fb27 | 16 | } |
| t00221592 | 0:f9e72987fb27 | 17 | } |