Summer lab Q2.4
Embed:
(wiki syntax)
Show/hide line numbers
main.cpp
00001 #include "mbed.h" 00002 DigitalIn fire(p14); 00003 PwmOut spkr(p26); 00004 AnalogIn pot1(p19);//declaring pot1, will be used to control the program 00005 float start=2000.0, end=10000.0, step=100.0; 00006 00007 int main() 00008 { 00009 while (1) { 00010 for (float i=start; i<end; i+=step) { 00011 spkr.period(1.0/i);//frequency calculations 00012 spkr=0.5; 00013 wait(0.1); 00014 } 00015 start =600.0;// starts the repeat sound at this frequency 00016 spkr=0.0; 00017 while(pot1.read() < 0.5) {} //use pot as repeat on_off 00018 } 00019 }
Generated on Wed Nov 1 2023 21:51:20 by
1.7.2