![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Potmeter FastPWM.h
main.cpp@0:16be67f4d9ac, 2017-09-19 (annotated)
- Committer:
- vd
- Date:
- Tue Sep 19 16:52:01 2017 +0000
- Revision:
- 0:16be67f4d9ac
Potmeter FastPWM.h
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
vd | 0:16be67f4d9ac | 1 | #include "mbed.h" |
vd | 0:16be67f4d9ac | 2 | #include "FastPWM.h" |
vd | 0:16be67f4d9ac | 3 | |
vd | 0:16be67f4d9ac | 4 | //DigitalOut gpo(D0); |
vd | 0:16be67f4d9ac | 5 | //DigitalOut ledr(D8); //PTA0 doesn't work |
vd | 0:16be67f4d9ac | 6 | DigitalOut ledl(D9); |
vd | 0:16be67f4d9ac | 7 | |
vd | 0:16be67f4d9ac | 8 | |
vd | 0:16be67f4d9ac | 9 | DigitalIn but1(D6); //D6 |
vd | 0:16be67f4d9ac | 10 | DigitalIn but2(D7); // Don't use D8 |
vd | 0:16be67f4d9ac | 11 | AnalogIn potmeter(A0); |
vd | 0:16be67f4d9ac | 12 | FastPWM ledr(D3); |
vd | 0:16be67f4d9ac | 13 | |
vd | 0:16be67f4d9ac | 14 | float PwnPeriod = 1.0/5000.0; |
vd | 0:16be67f4d9ac | 15 | |
vd | 0:16be67f4d9ac | 16 | |
vd | 0:16be67f4d9ac | 17 | int main() |
vd | 0:16be67f4d9ac | 18 | { |
vd | 0:16be67f4d9ac | 19 | ledr.period(PwnPeriod); |
vd | 0:16be67f4d9ac | 20 | |
vd | 0:16be67f4d9ac | 21 | |
vd | 0:16be67f4d9ac | 22 | |
vd | 0:16be67f4d9ac | 23 | while (true) { |
vd | 0:16be67f4d9ac | 24 | // gpo = !gpo; // toggle pin |
vd | 0:16be67f4d9ac | 25 | // led = !led; // toggle led |
vd | 0:16be67f4d9ac | 26 | |
vd | 0:16be67f4d9ac | 27 | ledr = potmeter.read(); |
vd | 0:16be67f4d9ac | 28 | wait(0.1f); |
vd | 0:16be67f4d9ac | 29 | |
vd | 0:16be67f4d9ac | 30 | |
vd | 0:16be67f4d9ac | 31 | //ledr = 0; |
vd | 0:16be67f4d9ac | 32 | |
vd | 0:16be67f4d9ac | 33 | //if (but1 == false) { |
vd | 0:16be67f4d9ac | 34 | //ledr = !ledr; |
vd | 0:16be67f4d9ac | 35 | //} |
vd | 0:16be67f4d9ac | 36 | |
vd | 0:16be67f4d9ac | 37 | //if (but2 == false) { |
vd | 0:16be67f4d9ac | 38 | //ledl = !ledl; |
vd | 0:16be67f4d9ac | 39 | //} |
vd | 0:16be67f4d9ac | 40 | |
vd | 0:16be67f4d9ac | 41 | } |
vd | 0:16be67f4d9ac | 42 | } |