Marc Mitchell
/
Options2014
Simple audio out using mbed templates
Revision 0:05e1cec99ce1, committed 2014-06-10
- Comitter:
- mm73
- Date:
- Tue Jun 10 12:14:05 2014 +0000
- Commit message:
- Options Girls 2014
Changed in this revision
Music_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 |
diff -r 000000000000 -r 05e1cec99ce1 Music_main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Music_main.cpp Tue Jun 10 12:14:05 2014 +0000 @@ -0,0 +1,50 @@ +#include "mbed.h" + +#define C3 131 +#define D3 147 +#define E3 165 +#define F3 175 +#define G3 196 +#define A3 220 +#define B3 247 +#define C4 262 +#define D4 294 +#define E4 330 +#define F4 349 +#define G4 392 +#define A4 440 +#define B4 494 +#define C5 523 +#define A5 880 +#define B5 988 +#define Pause 1 + +Ticker tick; +DigitalOut led1(LED_RED); +DigitalOut led2(LED_GREEN); +DigitalOut gpo(D10); + +void flip() { + led2 = !led2; + gpo = !gpo; +} + +int main() { + int Notes_Hz[] = {Pause, G4, F4, G4, Pause, D3, B5, A4, Pause, G4, E3, E4, E4, E4, F4, G4,Pause, + G4, F4, G4, Pause, D3, B5, A4, Pause, G4, E3, E4, E4, E4, F4, G4, Pause}; + int i; + int bpm = 120; + //tick.attach(&flip, 0.7); // setup ticker to call flip led2 after 0.7 seconds + + while (1) { + i = 0; + while (Notes_Hz[i]) { + led1 = !led1; + tick.attach(&flip, 0.5/Notes_Hz[i]); + wait (50.0/bpm); // bpm = beats per minute + tick.attach(&flip, 1); + wait (10.0/bpm); // + i++; + } + } +} \ No newline at end of file
diff -r 000000000000 -r 05e1cec99ce1 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Tue Jun 10 12:14:05 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/0b3ab51c8877 \ No newline at end of file