Preston Stephens
/
StarWars
Final
Fork of Smoke_Water by
main.cpp@1:2bf673cb2a16, 2016-01-24 (annotated)
- Committer:
- pstephens18
- Date:
- Sun Jan 24 00:37:02 2016 +0000
- Revision:
- 1:2bf673cb2a16
- Parent:
- 0:962d8d826218
Final;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
pstephens18 | 0:962d8d826218 | 1 | #include "mbed.h" |
pstephens18 | 0:962d8d826218 | 2 | |
pstephens18 | 0:962d8d826218 | 3 | PwmOut buzzer(p21); |
pstephens18 | 0:962d8d826218 | 4 | BusOut led(LED1,LED2,LED3,LED4); |
pstephens18 | 1:2bf673cb2a16 | 5 | float frequency[] = {262,0,262,0,262,0,349,0,523,0,466,0,440,0,392,0,698,0,523,0,466,0,440,0,392,0,698,0,523,0,466,0,440,0,466,0,392,0,/**/}; |
pstephens18 | 1:2bf673cb2a16 | 6 | float beat[] = {.3,0,.3,0,.3,0,2,0,2,0,.3,0,.3,0,.3,0,2,0,1,0,.3,0,.3,0,.3,0,2,0,1,0,.3,0,.3,0,.3,0,2,0/**/}; |
pstephens18 | 1:2bf673cb2a16 | 7 | float frequency2[] = {262,0,262,0,294,0,294,0,466,0,440,0,392,0,349,0,349,0,392,0,440,0,392,0,294,0,330,0,523,0,523,0,698,0,622,0,554,0,523,0,466,0,415,0,392,0,349,0,523,0}; |
pstephens18 | 1:2bf673cb2a16 | 8 | float beat2[] = {.75,0,.25,0,1.5,0,.5,0,.5,0,.5,0,.5,0,.5,0,.3,0,.3,0,.3,0,1,0,.5,0,1,0,.75,0,.25,0,1,0,.5,0,1,0,.5,0,1,0,.5,0,1,0,.5,0,4,0}; |
pstephens18 | 0:962d8d826218 | 9 | |
pstephens18 | 0:962d8d826218 | 10 | int main() { |
pstephens18 | 0:962d8d826218 | 11 | while(1) |
pstephens18 | 0:962d8d826218 | 12 | { |
pstephens18 | 1:2bf673cb2a16 | 13 | |
pstephens18 | 1:2bf673cb2a16 | 14 | for(int i=0; i<= 37;i++) |
pstephens18 | 0:962d8d826218 | 15 | { |
pstephens18 | 1:2bf673cb2a16 | 16 | buzzer.period(2/(frequency[i])); |
pstephens18 | 0:962d8d826218 | 17 | buzzer = 0.5; |
pstephens18 | 1:2bf673cb2a16 | 18 | |
pstephens18 | 0:962d8d826218 | 19 | wait(0.4*beat[i]); |
pstephens18 | 0:962d8d826218 | 20 | if(beat[i]==0) |
pstephens18 | 1:2bf673cb2a16 | 21 | {wait(.05);} |
pstephens18 | 0:962d8d826218 | 22 | |
pstephens18 | 0:962d8d826218 | 23 | } |
pstephens18 | 1:2bf673cb2a16 | 24 | |
pstephens18 | 1:2bf673cb2a16 | 25 | for(int i=0; i<= 49;i++) |
pstephens18 | 1:2bf673cb2a16 | 26 | { |
pstephens18 | 1:2bf673cb2a16 | 27 | buzzer.period(2/(frequency2[i])); |
pstephens18 | 1:2bf673cb2a16 | 28 | buzzer = 0.5; |
pstephens18 | 1:2bf673cb2a16 | 29 | |
pstephens18 | 1:2bf673cb2a16 | 30 | wait(0.4*beat2[i]); |
pstephens18 | 1:2bf673cb2a16 | 31 | if(beat2[i]==0) |
pstephens18 | 1:2bf673cb2a16 | 32 | {wait(.05);} |
pstephens18 | 1:2bf673cb2a16 | 33 | |
pstephens18 | 1:2bf673cb2a16 | 34 | } |
pstephens18 | 1:2bf673cb2a16 | 35 | |
pstephens18 | 0:962d8d826218 | 36 | } |
pstephens18 | 0:962d8d826218 | 37 | } |