Alejandro Montes
/
Experiment_4
IT Tralee Life Long Learning 2020 Instrumentation, Monitoring and Control Module Laboratory Session
LAB_2.4.cpp@0:fa653a534c74, 2020-07-27 (annotated)
- Committer:
- alejandromontes
- Date:
- Mon Jul 27 20:30:21 2020 +0000
- Revision:
- 0:fa653a534c74
Alejandro Montes Instrumentation Monitoring and Control LAB
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
alejandromontes | 0:fa653a534c74 | 1 | #include "mbed.h" |
alejandromontes | 0:fa653a534c74 | 2 | |
alejandromontes | 0:fa653a534c74 | 3 | DigitalIn fire(p14); |
alejandromontes | 0:fa653a534c74 | 4 | PwmOut spkr(p26); |
alejandromontes | 0:fa653a534c74 | 5 | AnalogIn pot1(p19); |
alejandromontes | 0:fa653a534c74 | 6 | float start=2000.0; |
alejandromontes | 0:fa653a534c74 | 7 | float end=10000.0; |
alejandromontes | 0:fa653a534c74 | 8 | float step=200.0; |
alejandromontes | 0:fa653a534c74 | 9 | |
alejandromontes | 0:fa653a534c74 | 10 | int main(){ |
alejandromontes | 0:fa653a534c74 | 11 | while (1) { |
alejandromontes | 0:fa653a534c74 | 12 | for (float i=start; i<end; i+=step) { |
alejandromontes | 0:fa653a534c74 | 13 | spkr.period(5.0/i); |
alejandromontes | 0:fa653a534c74 | 14 | spkr=(0.5); |
alejandromontes | 0:fa653a534c74 | 15 | wait(0.1); |
alejandromontes | 0:fa653a534c74 | 16 | } |
alejandromontes | 0:fa653a534c74 | 17 | spkr=0.0; |
alejandromontes | 0:fa653a534c74 | 18 | start=8000.0; |
alejandromontes | 0:fa653a534c74 | 19 | while(pot1.read() < 0.5) {} // this uses the pot1 to control the program |
alejandromontes | 0:fa653a534c74 | 20 | } |
alejandromontes | 0:fa653a534c74 | 21 | } |