Speaker_3

Dependencies:   mbed

main.cpp

Committer:
mariana_batalim
Date:
2020-06-20
Revision:
0:4a38049f8bdd
Child:
1:76c01cff7a71

File content as of revision 0:4a38049f8bdd:

#include "mbed.h"

DigitalIn fire(p14);
PwmOut spkr(p26);
AnalogIn pot1(p19);
float start=2000.0;
float end=10000.0;
float step=200.0;

int main(){
    while (1) {
        for (float i=start; i<end; i+=step) {
        spkr.period(5.0/i);
        spkr=(0.5);
        wait(0.1);
        }
    spkr=0.0;
    start=7000.0;
    while(pot1.read() < 0.5) {} // this uses the pot to control the program
    }
}