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.
main.cpp
00001 #include "mbed.h" 00002 00003 PwmOut speaker(p21); 00004 float frequency = 800; 00005 float wait_time = 1.000; 00006 InterruptIn boom(p5); 00007 void detonation(); 00008 00009 int main() 00010 { 00011 boom.rise(&detonation); 00012 while(1) 00013 { 00014 speaker.period(1.0/(2.0*frequency)); 00015 speaker = 0.5; 00016 wait(0.15); 00017 speaker = 0; 00018 wait(0.35); 00019 speaker.period(1.0/(2.0*(frequency + 100))); 00020 speaker = 0.5; 00021 wait(0.15); 00022 speaker = 0; 00023 wait(wait_time); 00024 frequency++; 00025 wait_time = wait_time - 0.002; 00026 } 00027 } 00028 00029 void detonation() 00030 { 00031 for(int i = 0; i < 20; i++) 00032 { 00033 speaker.period(1.0/(2.0*frequency + 100)); 00034 speaker = 0.5; 00035 wait(0.05); 00036 speaker = 0; 00037 wait(0.02); 00038 speaker.period(1.0/(2.0*(frequency + 100))); 00039 speaker = 0.5; 00040 wait(0.05); 00041 speaker = 0; 00042 wait(0.02); 00043 } 00044 speaker.period(1.0/(2.0*200)); 00045 speaker = 0.4; 00046 wait(2); 00047 00048 }
Generated on Fri Jul 15 2022 11:20:57 by
1.7.2