A simple 1 kHz PWM signal generator with adjustable duty cycle over potentiometer.

Dependencies:   mbed

Committer:
tbjazic
Date:
Thu Dec 18 12:18:08 2014 +0000
Revision:
0:61ad02148730
Initial commit.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
tbjazic 0:61ad02148730 1 #include "mbed.h"
tbjazic 0:61ad02148730 2
tbjazic 0:61ad02148730 3 PwmOut pwm(p21);
tbjazic 0:61ad02148730 4 AnalogIn pot1(p19);
tbjazic 0:61ad02148730 5
tbjazic 0:61ad02148730 6 int main() {
tbjazic 0:61ad02148730 7 pwm.period(0.001); // 1 kHz or 1 ms
tbjazic 0:61ad02148730 8 while(1) {
tbjazic 0:61ad02148730 9 pwm = pot1;
tbjazic 0:61ad02148730 10 }
tbjazic 0:61ad02148730 11 }