ArmfulKST / Mbed 2 deprecated music_sequencer

Dependencies:   mbed

Fork of mbed_blinky by Mbed

Files at this revision

API Documentation at this revision

Comitter:
f3d
Date:
Tue Nov 18 12:30:47 2014 +0000
Parent:
6:e8cd76f38fa9
Commit message:
v1

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Fri May 09 19:58:03 2014 +0300
+++ b/main.cpp	Tue Nov 18 12:30:47 2014 +0000
@@ -1,12 +1,25 @@
 #include "mbed.h"
 
-DigitalOut myled(LED1);
+DigitalOut speaker(D2);
 
+void tone(float freq, float len)
+{
+    float half_cycle;
+    int cyclecount;
+    half_cycle=(1.0/freq)/2.0;
+    cyclecount=freq*len;
+    while(cyclecount--)
+    {
+        speaker=1;
+        wait(half_cycle);
+        speaker=0;
+        wait(half_cycle);
+    }    
+}
 int main() {
     while(1) {
-        myled = 1;
-        wait(0.2);
-        myled = 0;
-        wait(0.2);
+     
+        tone(261,0.5);
+        wait(0.5);
     }
 }
--- a/mbed.bld	Fri May 09 19:58:03 2014 +0300
+++ b/mbed.bld	Tue Nov 18 12:30:47 2014 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/
\ No newline at end of file
+http://mbed.org/users/mbed_official/code/mbed/builds/031413cf7a89
\ No newline at end of file