![](/media/cache/group/DffTeam_Yf25WvB.jpg.50x50_q85.jpg)
Esercitazione 2 - 2
Dependencies: mbed
Diff: main.cpp
- Revision:
- 0:1340878988a7
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Mon Oct 10 09:34:00 2016 +0000 @@ -0,0 +1,13 @@ +//Program Example 2: Uses analog input to control PWM duty cycle, fixed period + +#include "mbed.h" + +PwmOut PWM1(D5); +AnalogIn Ain(A0); //defines analog input on A0 +int main(){ + while(1){ + PWM1.period(0.010); // set PWM period to 10 ms + PWM1=Ain; //Analog in value becomes PWM duty, both are type float + wait(0.1); + } +} \ No newline at end of file