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.
Revision 1:7fdec2560f78, committed 2015-01-09
- Comitter:
- ffxx68
- Date:
- Fri Jan 09 18:00:42 2015 +0000
- Parent:
- 0:59717cf94c6a
- Commit message:
- fixed
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Fri Jan 09 17:46:14 2015 +0000
+++ b/main.cpp Fri Jan 09 18:00:42 2015 +0000
@@ -50,10 +50,9 @@
pc.printf ("Tone...\n");
// generate a short 150Hz tone using PWM hardware output
// something like this can be used for a button click effect for feedback
- speaker =0.25; //25% duty cycle - mid range volume
for (i=0; i<10; i++) {
speaker.period(1.0/150.0); // 500hz period
-
+ speaker =0.25; //25% duty cycle - mid range volume
wait(.02);
}
speaker=0.0; // off
@@ -62,9 +61,9 @@
case 's':
pc.printf ("Sweep...\n");
// sweep up in frequency by changing the PWM period
- speaker=0.25;
for (i=0; i<8000; i=i+100) {
speaker.period(1.0/float(i));
+ speaker=0.25;
wait(.02);
}
speaker=0.0; // off
@@ -74,7 +73,7 @@
pc.printf ("Police...\n");
// two tone police siren effect - two periods or two frequencies
// increase volume - by changing the PWM duty cycle
- for (i=0; i<26; i=i+2) {
+ for (i=0; i<10; i=i+2) {
speaker.period(1.0/969.0);
speaker = float(i)/50.0;
wait(.5);
@@ -85,10 +84,10 @@
break;
case 'h':
- // Play "happy birthday"
- speaker=0.25;
+ pc.printf ("Happy birthday...\n");
for (int i=0;i<=24;i++) {
speaker.period(1.0/notes[i]);
+ speaker=0.25;
wait(0.8*intervals[i]/10);
}
speaker=0.0; // off