Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
main.cpp@0:9df24d9c5f46, 2019-03-26 (annotated)
- Committer:
- khalish18
- Date:
- Tue Mar 26 10:38:54 2019 +0000
- Revision:
- 0:9df24d9c5f46
brighness
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
khalish18 | 0:9df24d9c5f46 | 1 | /*Program Example 5.2: Uses analog input to control PWM duty cycle, fixed period |
khalish18 | 0:9df24d9c5f46 | 2 | */ |
khalish18 | 0:9df24d9c5f46 | 3 | #include "mbed.h" |
khalish18 | 0:9df24d9c5f46 | 4 | PwmOut PWM1(p21); |
khalish18 | 0:9df24d9c5f46 | 5 | AnalogIn Ain(p20); //defines analog input on Pin 20 |
khalish18 | 0:9df24d9c5f46 | 6 | |
khalish18 | 0:9df24d9c5f46 | 7 | int main() { |
khalish18 | 0:9df24d9c5f46 | 8 | while(1) { |
khalish18 | 0:9df24d9c5f46 | 9 | PWM1.period(Ain/1000 + 0.001); |
khalish18 | 0:9df24d9c5f46 | 10 | PWM1=Ain; |
khalish18 | 0:9df24d9c5f46 | 11 | wait(0.5); |
khalish18 | 0:9df24d9c5f46 | 12 | } |
khalish18 | 0:9df24d9c5f46 | 13 | } |
khalish18 | 0:9df24d9c5f46 | 14 |