
Speakers
Diff: main.cpp
- Revision:
- 4:d693dc6d6e78
- Parent:
- 3:4e35f0d99e64
--- a/main.cpp Fri Feb 21 20:30:41 2014 +0000 +++ b/main.cpp Tue Jul 28 11:55:46 2020 +0000 @@ -1,14 +1,18 @@ -#include "mbed.h" +#include "mbed.h" //Preprocessor Directives + +DigitalIn fire(p14); // Declarations +PwmOut spkr(p26); +AnalogIn pot1(p19); -DigitalOut myled(LED1); -DigitalOut myled2(LED2); -int main() { - while(1) { - myled = 1; - myled2 = 0; - wait(0.5); - myled = 0; - myled2 = 1; - wait(0.5); +int main() //instructions in main () function +{ + while (1) { + for (float i=2000.0; i<10000.0; i+=100) { + spkr.period(1.0/i); + spkr=0.5; + wait(0.1); + } + spkr=0.0; + while(pot1.read() < 0.5) {} // this uses the pot to control the program } }