Kian Sek Tee
/
beeper1
Bee rythm. Use arraty s and pointer
Diff: main.cpp
- Revision:
- 0:9bae60bd8b98
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Fri Feb 26 18:18:45 2010 +0000 @@ -0,0 +1,49 @@ +#include "mbed.h" +#include "Beeper.h" +#include "TextLCD.h" + + +Beeper myBeeper(p21); +AnalogIn ain(p20); +TextLCD lcd(p24, p25, p26, p27, p28, p29, p30); // rs, rw, e, d0, d1, d2, d3 +float f; +float C4, D4, E4, F4, G4, A4, B4, C5; //keys +float t=.2; //tempol +int p=0; +int size; + +const float freq[8] = {261.63, 293.67, 329.63, 349.23, 392.00, 440.00,493.88, 523.25}; +//const char freq[2] = {C4, D5}; + +const int song[] = {5,3,3, + 4,2,2, + 1,2,3,4, + 5,5,5, + 5,3,3, + 4,2,2, + 1,3,5,5,1,1, + 2,2,2,2, + 2,3,4, + 3,3,3,3, + 3,4,5, + 5,3,3, + 4,2,2, + 1,3,5,5,1, 1 + }; + +int main() { + + size=sizeof(song)/sizeof(*song); // size of element in the array + while (1) { + for (int i = 0; i <size-1; i++) { + p=song[i]; +// wait(1); + myBeeper.beep(freq[p-1], t); + lcd.locate(0,0); + lcd.printf("%d",sizeof(song)); + lcd.locate(0,1); + lcd.printf("%d",sizeof(*song)); + + } + } +} \ No newline at end of file