Dependencies: mbed
main.cpp@0:30ef0b226adf, 2017-03-01 (annotated)
- Committer:
- jderemer3
- Date:
- Wed Mar 01 16:38:41 2017 +0000
- Revision:
- 0:30ef0b226adf
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jderemer3 | 0:30ef0b226adf | 1 | #include "mbed.h" |
jderemer3 | 0:30ef0b226adf | 2 | |
jderemer3 | 0:30ef0b226adf | 3 | PwmOut driv(p21); |
jderemer3 | 0:30ef0b226adf | 4 | |
jderemer3 | 0:30ef0b226adf | 5 | int main() { |
jderemer3 | 0:30ef0b226adf | 6 | // specify period first |
jderemer3 | 0:30ef0b226adf | 7 | driv.period(0.0125f); // 4 second period |
jderemer3 | 0:30ef0b226adf | 8 | //driv.write(0.5f); // 50% duty cycle, relative to period |
jderemer3 | 0:30ef0b226adf | 9 | //led = 0.5f; // shorthand for led.write() |
jderemer3 | 0:30ef0b226adf | 10 | //led.pulsewidth(2); // alternative to led.write, set duty cycle time in seconds |
jderemer3 | 0:30ef0b226adf | 11 | while(1) |
jderemer3 | 0:30ef0b226adf | 12 | { |
jderemer3 | 0:30ef0b226adf | 13 | for (int i = 0; i < 10; i++) |
jderemer3 | 0:30ef0b226adf | 14 | { |
jderemer3 | 0:30ef0b226adf | 15 | float inc = i*0.1f; |
jderemer3 | 0:30ef0b226adf | 16 | driv.write(inc); |
jderemer3 | 0:30ef0b226adf | 17 | wait(1); |
jderemer3 | 0:30ef0b226adf | 18 | } |
jderemer3 | 0:30ef0b226adf | 19 | } |
jderemer3 | 0:30ef0b226adf | 20 | } |