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 0:2309ea52d6c9, committed 2011-12-26
- Comitter:
- yueee_yt
- Date:
- Mon Dec 26 13:13:15 2011 +0000
- Commit message:
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 |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Mon Dec 26 13:13:15 2011 +0000 @@ -0,0 +1,64 @@ +#define mC 261.626 +#define mD 293.665 +#define mE 329.628 +#define mF 349.228 +#define mG 391.995 +#define mA 440.000 +#define mB 493.883 + +#include "mbed.h" + +Ticker timer; +AnalogOut sp1(p18); +float ms[180]; +float m1,m2,m3; + +void sound_out(void) { + static float j1=0; + static float j2=0; + static float j3=0; + j1=j1+m1; + j2=j2+m2; + j3=j3+m3; + if (j1>180)j1=j1-180; + if (j2>180)j2=j2-180; + if (j3>180)j3=j3-180; + sp1.write((ms[(int)j1]+ms[(int)j2]+ms[(int)j3])/3.0); +} + +int main() { + int i; + //setting sincurv + for (i=0;i<180;i++) { + ms[i]=sin(2*3.1415*(float)i/180.0)/2.0+0.5; + } + timer.attach_us(&sound_out,10); //10kHz + //ceg + m1=mC*2*180/100000; + m2=mE*2*180/100000; + m3=mG*2*180/100000; + wait(1.0f); + //cfa + m1=mC*2*180/100000; + m2=mF*2*180/100000; + m3=mA*2*180/100000; + wait(1.0f); + //ceg + m1=mC*2*180/100000; + m2=mE*2*180/100000; + m3=mG*2*180/100000; + wait(1.0f); + //bdg + m1=mB*180/100000; + m2=mD*2*180/100000; + m3=mG*2*180/100000; + wait(1.0f); + //ceg + m1=mC*2*180/100000; + m2=mE*2*180/100000; + m3=mG*2*180/100000; + wait(1.0f); + timer.detach(); + sp1.write(0.0f); + while (1); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Mon Dec 26 13:13:15 2011 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/078e4b97a13e