My change.

Dependencies:   mbed

Fork of app-board-Speaker by Chris Styles

Files at this revision

API Documentation at this revision

Comitter:
209108
Date:
Wed Mar 05 03:49:12 2014 +0000
Parent:
2:cfd337edff08
Commit message:
Plays sound in a sine wave pitch pattern.
;

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r cfd337edff08 -r 00613a6b0e8b main.cpp
--- a/main.cpp	Thu Oct 25 12:25:00 2012 +0000
+++ b/main.cpp	Wed Mar 05 03:49:12 2014 +0000
@@ -2,12 +2,14 @@
 
 DigitalIn fire(p14);
 PwmOut spkr(p26);
+float theta = 0;
 
 int main()
 {
     while (1) {
-        for (float i=2000.0; i<10000.0; i+=100) {
-            spkr.period(1.0/i);
+        for (float i=2000.0; i>0.0; i+=100) {
+            theta += .2;
+            spkr.period(sin(theta)/1000);
             spkr=0.5;
             wait(0.1);
         }