Mariana Batalim
/
speaker
T00215868_Speaker with alternate sound
Revision 0:1ddbd3937128, committed 2020-06-20
- Comitter:
- mariana_batalim
- Date:
- Sat Jun 20 12:02:52 2020 +0000
- Commit message:
- T00215868_Speaker with alternate sound
Changed in this revision
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 |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sat Jun 20 12:02:52 2020 +0000 @@ -0,0 +1,21 @@ +#include "mbed.h" +DigitalIn fire(p14); +PwmOut spkr(p26); +AnalogIn pot1(p19); +int main() +{ + while (1) { + {for (float i=2000.0; i<10000.0; i+=100) { + spkr.period(1.0/i); + spkr=0.5; + wait(0.1);} + {for (float i=2000.0; i<10000.0; i+=300) { + spkr.period(1.0/i); + spkr=0.9; + wait(0.3);} + } + spkr=0.0; + while(pot1.read() < 0.5) {} // this uses the pot to control the program + } +} +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Sat Jun 20 12:02:52 2020 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400 \ No newline at end of file