Bertie Harte / Mbed 2 deprecated Intrumentation_lab_2_4_1_Speakermodified

Dependencies:   mbed

Committer:
BertieHarte
Date:
Sun Jul 28 09:44:44 2019 +0000
Revision:
0:5742b01051e5
Child:
1:760c5b759868
Version 1 initial code form handout

Who changed what in which revision?

UserRevisionLine numberNew contents of line
BertieHarte 0:5742b01051e5 1 #include "mbed.h"
BertieHarte 0:5742b01051e5 2
BertieHarte 0:5742b01051e5 3 DigitalIn fire(p14); // centre pin of joystick.
BertieHarte 0:5742b01051e5 4 PwmOut spkr(p26); // speaker output
BertieHarte 0:5742b01051e5 5
BertieHarte 0:5742b01051e5 6 int main() {
BertieHarte 0:5742b01051e5 7 while(1) {
BertieHarte 0:5742b01051e5 8 for (float i=2000.0; i<10000; i+=100) { // increment i by 200 each loop if the value at teh start of the loo is less than 1000
BertieHarte 0:5742b01051e5 9 spkr.period(1.0/i);
BertieHarte 0:5742b01051e5 10 spkr=0.5;
BertieHarte 0:5742b01051e5 11 wait(0.1);
BertieHarte 0:5742b01051e5 12 }
BertieHarte 0:5742b01051e5 13 spkr=0.0;
BertieHarte 0:5742b01051e5 14 while(!fire) {}
BertieHarte 0:5742b01051e5 15 }
BertieHarte 0:5742b01051e5 16 }