![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
CA 2.4 Original Code
main.cpp@0:c2e106c9f2eb, 2020-07-26 (annotated)
- Committer:
- vmg
- Date:
- Sun Jul 26 20:58:58 2020 +0000
- Revision:
- 0:c2e106c9f2eb
CA 2.4 Original Code
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
vmg | 0:c2e106c9f2eb | 1 | #include "mbed.h" |
vmg | 0:c2e106c9f2eb | 2 | |
vmg | 0:c2e106c9f2eb | 3 | DigitalIn fire(p14); |
vmg | 0:c2e106c9f2eb | 4 | PwmOut spkr(p26); |
vmg | 0:c2e106c9f2eb | 5 | AnalogIn pot1(p19); |
vmg | 0:c2e106c9f2eb | 6 | int main(){ |
vmg | 0:c2e106c9f2eb | 7 | while (1) { |
vmg | 0:c2e106c9f2eb | 8 | for (float i=2000.0; i<10000.0; i+=100) { |
vmg | 0:c2e106c9f2eb | 9 | spkr.period(1.0/i); |
vmg | 0:c2e106c9f2eb | 10 | spkr=0.5; |
vmg | 0:c2e106c9f2eb | 11 | wait(0.1); |
vmg | 0:c2e106c9f2eb | 12 | } |
vmg | 0:c2e106c9f2eb | 13 | spkr=0.0; |
vmg | 0:c2e106c9f2eb | 14 | while(pot1.read() < 0.5) {} // this uses the pot to control the program |
vmg | 0:c2e106c9f2eb | 15 | } |
vmg | 0:c2e106c9f2eb | 16 | } |