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.
Dependencies: C12832 MMA7660 mbed
sound.cpp@0:c3bc6981ad28, 2018-01-31 (annotated)
- Committer:
- ksaito
- Date:
- Wed Jan 31 10:58:19 2018 +0000
- Revision:
- 0:c3bc6981ad28
- Child:
- 1:2967eac08981
???????
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| ksaito | 0:c3bc6981ad28 | 1 | #include "mbed.h" |
| ksaito | 0:c3bc6981ad28 | 2 | |
| ksaito | 0:c3bc6981ad28 | 3 | PwmOut spkr(p26); |
| ksaito | 0:c3bc6981ad28 | 4 | |
| ksaito | 0:c3bc6981ad28 | 5 | void SoundInitialize(void) { |
| ksaito | 0:c3bc6981ad28 | 6 | spkr=0.0; |
| ksaito | 0:c3bc6981ad28 | 7 | } |
| ksaito | 0:c3bc6981ad28 | 8 | |
| ksaito | 0:c3bc6981ad28 | 9 | void SoundProcess(void) { |
| ksaito | 0:c3bc6981ad28 | 10 | for (float i = 2000.0; i < 10000.0; i += 100) { |
| ksaito | 0:c3bc6981ad28 | 11 | spkr.period(1.0 / i); |
| ksaito | 0:c3bc6981ad28 | 12 | spkr = 0.5; |
| ksaito | 0:c3bc6981ad28 | 13 | wait(0.1); |
| ksaito | 0:c3bc6981ad28 | 14 | } |
| ksaito | 0:c3bc6981ad28 | 15 | } |
| ksaito | 0:c3bc6981ad28 | 16 | |
| ksaito | 0:c3bc6981ad28 | 17 | void SoundFinalize(void) { |
| ksaito | 0:c3bc6981ad28 | 18 | SoundInitialize(); |
| ksaito | 0:c3bc6981ad28 | 19 | } |