05-03 PWMFrequency
From Manuals
(Difference between revisions)
| (3 intermediate revisions not shown) | |||
| Line 26: | Line 26: | ||
|S2-3 | |S2-3 | ||
|S2-3 | |S2-3 | ||
| + | |LED | ||
|- | |- | ||
|} | |} | ||
| Line 47: | Line 48: | ||
} | } | ||
| - | [[Image: | + | PWM1 was captured on Channel 1 of the oscilloscope and AIN1 on channel 2 in the image below. |
| + | [[Image:BAM210_05_03.png|center|]] | ||
| + | |||
| + | The following image shows the built circuit on a BAM210E. | ||
| + | [[Image:BAM210_PWMPulse.jpeg|center|]] | ||
Current revision as of 14:48, 18 September 2014
This example program uses an analog input to control the period of a PWM.
The signals used for this example are listed below:
| Signal | LPC4330 PIN NAME | BAM210E | BAM210 | BAM200E | BAM200 | Used for |
| A0 | P7_4 | J8-1 | J8-1 | S4-3 | S4-3 | Potentiometer |
| PWM1 | P1_7 | J9-3 | J9-3 | S2-3 | S2-3 | LED |
The following schematic can be used to build the circuit with a BAM210E or BAM210.
/*Program Example 5.3: Uses analog input to control PWM period
*/
#include "mbed.h"
PwmOut pwm(PWM1);
AnalogIn Ain(A0);
int main() {
while(1){
pwm.period(Ain/10+0.001); // set PWM period
pwm=0.5; // set duty cycle
wait(0.5);
}
}
PWM1 was captured on Channel 1 of the oscilloscope and AIN1 on channel 2 in the image below.
The following image shows the built circuit on a BAM210E.



