![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
working
main.cpp@0:962d8d826218, 2016-01-20 (annotated)
- Committer:
- pstephens18
- Date:
- Wed Jan 20 21:45:59 2016 +0000
- Revision:
- 0:962d8d826218
Playing a bit Fast
;
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 | 0:962d8d826218 | 5 | float frequency[] = {622,0,784,0,880,0,622,0,784,0,923,880,0,622,0,784,0,880,0,784,0,622,0}; |
pstephens18 | 0:962d8d826218 | 6 | float beat[] = {.5,0,.5,0,1.25,0,.5,0,.5,0,.5,1.5,0,.5,0,.5,0,1,0,.5,0,1.5,0}; |
pstephens18 | 0:962d8d826218 | 7 | |
pstephens18 | 0:962d8d826218 | 8 | int main() { |
pstephens18 | 0:962d8d826218 | 9 | while(1) |
pstephens18 | 0:962d8d826218 | 10 | { |
pstephens18 | 0:962d8d826218 | 11 | for(int i=0; i<= 23;i++) |
pstephens18 | 0:962d8d826218 | 12 | { |
pstephens18 | 0:962d8d826218 | 13 | buzzer.period(4/(frequency[i])); |
pstephens18 | 0:962d8d826218 | 14 | buzzer = 0.5; |
pstephens18 | 0:962d8d826218 | 15 | if(frequency[i]== 622){led =1;} |
pstephens18 | 0:962d8d826218 | 16 | if(frequency[i]== 784){led =2;} |
pstephens18 | 0:962d8d826218 | 17 | if(frequency[i]== 880){led =4;} |
pstephens18 | 0:962d8d826218 | 18 | if(frequency[i]== 923){led = 8;} |
pstephens18 | 0:962d8d826218 | 19 | |
pstephens18 | 0:962d8d826218 | 20 | wait(0.4*beat[i]); |
pstephens18 | 0:962d8d826218 | 21 | |
pstephens18 | 0:962d8d826218 | 22 | if(beat[i]==0) |
pstephens18 | 0:962d8d826218 | 23 | {wait(.15);} |
pstephens18 | 0:962d8d826218 | 24 | |
pstephens18 | 0:962d8d826218 | 25 | } |
pstephens18 | 0:962d8d826218 | 26 | } |
pstephens18 | 0:962d8d826218 | 27 | } |