
InstrumentationQ4
main.cpp@0:5918c9abc1ce, 2020-08-16 (annotated)
- Committer:
- liammchale
- Date:
- Sun Aug 16 21:47:23 2020 +0000
- Revision:
- 0:5918c9abc1ce
Instrumentation Q4
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
liammchale | 0:5918c9abc1ce | 1 | #include "mbed.h" //preprosser commands |
liammchale | 0:5918c9abc1ce | 2 | |
liammchale | 0:5918c9abc1ce | 3 | DigitalIn fire(p14); //global declarations |
liammchale | 0:5918c9abc1ce | 4 | PwmOut spkr(p26); |
liammchale | 0:5918c9abc1ce | 5 | AnalogIn pot1(p19); |
liammchale | 0:5918c9abc1ce | 6 | float start = 2000.0, end = 10000.0, step = 100;//variables |
liammchale | 0:5918c9abc1ce | 7 | |
liammchale | 0:5918c9abc1ce | 8 | int main() //main program |
liammchale | 0:5918c9abc1ce | 9 | { |
liammchale | 0:5918c9abc1ce | 10 | while (1) { |
liammchale | 0:5918c9abc1ce | 11 | for (float i=start; i<end; i+=step) { |
liammchale | 0:5918c9abc1ce | 12 | spkr.period(1.0/i); |
liammchale | 0:5918c9abc1ce | 13 | spkr=0.5; |
liammchale | 0:5918c9abc1ce | 14 | wait(0.1); |
liammchale | 0:5918c9abc1ce | 15 | } |
liammchale | 0:5918c9abc1ce | 16 | spkr=0.0; |
liammchale | 0:5918c9abc1ce | 17 | start = 3000.0; |
liammchale | 0:5918c9abc1ce | 18 | end = 5000.0; |
liammchale | 0:5918c9abc1ce | 19 | while(pot1.read() < 0.5) {} // this uses the pot to control the program |
liammchale | 0:5918c9abc1ce | 20 | } |
liammchale | 0:5918c9abc1ce | 21 | } |