A simple 1 kHz PWM signal generator with 50% duty cycle.
Dependencies: mbed
main.cpp@0:53a5be91e9dc, 2014-12-18 (annotated)
- Committer:
- tbjazic
- Date:
- Thu Dec 18 11:59:40 2014 +0000
- Revision:
- 0:53a5be91e9dc
Initial commit.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
tbjazic | 0:53a5be91e9dc | 1 | #include "mbed.h" |
tbjazic | 0:53a5be91e9dc | 2 | |
tbjazic | 0:53a5be91e9dc | 3 | PwmOut pwm(p21); |
tbjazic | 0:53a5be91e9dc | 4 | |
tbjazic | 0:53a5be91e9dc | 5 | int main() { |
tbjazic | 0:53a5be91e9dc | 6 | pwm.period(0.001); // 1 kHz or 1 ms |
tbjazic | 0:53a5be91e9dc | 7 | while(1) { |
tbjazic | 0:53a5be91e9dc | 8 | pwm = 0.5; |
tbjazic | 0:53a5be91e9dc | 9 | } |
tbjazic | 0:53a5be91e9dc | 10 | } |