Speaker_2

Dependencies:   mbed

Committer:
jforde
Date:
Tue Jul 28 11:57:33 2020 +0000
Revision:
0:4f7181c56953
Speaker_2

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jforde 0:4f7181c56953 1 #include "mbed.h" //Preprocessor Directives
jforde 0:4f7181c56953 2
jforde 0:4f7181c56953 3 DigitalIn fire(p14); // Declarations
jforde 0:4f7181c56953 4 PwmOut spkr(p26);
jforde 0:4f7181c56953 5 AnalogIn pot1(p19);
jforde 0:4f7181c56953 6 float start=2000.0;
jforde 0:4f7181c56953 7 float end=10000.0;
jforde 0:4f7181c56953 8 float step=100;
jforde 0:4f7181c56953 9
jforde 0:4f7181c56953 10
jforde 0:4f7181c56953 11 int main(){ //instructions in main () function
jforde 0:4f7181c56953 12 while (1) {
jforde 0:4f7181c56953 13 for (float i=start; i<end; i+=step) {
jforde 0:4f7181c56953 14 spkr.period(5.0/i);
jforde 0:4f7181c56953 15 spkr=(0.5);
jforde 0:4f7181c56953 16 wait(0.1);
jforde 0:4f7181c56953 17 }
jforde 0:4f7181c56953 18 spkr=0.0;
jforde 0:4f7181c56953 19 start=3000.0;
jforde 0:4f7181c56953 20 while(pot1.read() < 0.5) {} // this uses the pot to control the program
jforde 0:4f7181c56953 21 }
jforde 0:4f7181c56953 22 }