Rob Toulson / Mbed 2 deprecated PE_05-03_PWMFrequency

Dependencies:   mbed

Committer:
robt
Date:
Mon Oct 15 21:18:09 2012 +0000
Revision:
0:e53d3f40f2c7
by Rob Toulson and Tim Wilmshurst from textbook "Fast and Effective Embedded Systems Design: Applying the ARM mbed"

Who changed what in which revision?

UserRevisionLine numberNew contents of line
robt 0:e53d3f40f2c7 1 /*Program Example 5.3: Uses analog input to control PWM period
robt 0:e53d3f40f2c7 2 */
robt 0:e53d3f40f2c7 3 #include "mbed.h"
robt 0:e53d3f40f2c7 4 PwmOut PWM1(p21);
robt 0:e53d3f40f2c7 5 AnalogIn Ain(p20);
robt 0:e53d3f40f2c7 6
robt 0:e53d3f40f2c7 7 int main() {
robt 0:e53d3f40f2c7 8 while(1){
robt 0:e53d3f40f2c7 9 PWM1.period(Ain/10+0.001); // set PWM period
robt 0:e53d3f40f2c7 10 PWM1=0.5; // set duty cycle
robt 0:e53d3f40f2c7 11 wait(0.5);
robt 0:e53d3f40f2c7 12 }
robt 0:e53d3f40f2c7 13 }
robt 0:e53d3f40f2c7 14