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: mbed
main.cpp@2:68eee0fb2026, 2014-10-21 (annotated)
- Committer:
- 4180_1
- Date:
- Tue Oct 21 03:14:51 2014 +0000
- Revision:
- 2:68eee0fb2026
- Parent:
- 0:b2fdf3770282
- Child:
- 3:61d42134c1be
ver 1.1
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| 4180_1 | 0:b2fdf3770282 | 1 | #include "mbed.h" |
| 4180_1 | 0:b2fdf3770282 | 2 | #include "Speaker.h" |
| 4180_1 | 0:b2fdf3770282 | 3 | |
| 4180_1 | 0:b2fdf3770282 | 4 | // Speaker test program - euro police style siren now using new Speaker class method |
| 4180_1 | 0:b2fdf3770282 | 5 | // for documentation see http://mbed.org/users/4180_1/notebook/using-a-speaker-for-audio-output/ |
| 4180_1 | 2:68eee0fb2026 | 6 | // can also be used to play a song, if you have all of the notes and durations |
| 4180_1 | 0:b2fdf3770282 | 7 | // for musical note frequencies see http://en.wikipedia.org/wiki/Piano_key_frequencies |
| 4180_1 | 0:b2fdf3770282 | 8 | |
| 4180_1 | 0:b2fdf3770282 | 9 | int main() |
| 4180_1 | 0:b2fdf3770282 | 10 | { |
| 4180_1 | 0:b2fdf3770282 | 11 | // setup instance of new Speaker class, mySpeaker using pin 21 |
| 4180_1 | 0:b2fdf3770282 | 12 | // the pin must be a PWM output pin |
| 4180_1 | 0:b2fdf3770282 | 13 | Speaker mySpeaker(p21); |
| 4180_1 | 0:b2fdf3770282 | 14 | // loops forever playing two notes on speaker |
| 4180_1 | 0:b2fdf3770282 | 15 | while(1) { |
| 4180_1 | 0:b2fdf3770282 | 16 | mySpeaker.PlayNote(969.0,0.5,0.5); |
| 4180_1 | 0:b2fdf3770282 | 17 | mySpeaker.PlayNote(800.0,0.5,0.5); |
| 4180_1 | 0:b2fdf3770282 | 18 | } |
| 4180_1 | 0:b2fdf3770282 | 19 | } |
| 4180_1 | 2:68eee0fb2026 | 20 |