Alejandro Forero / Mbed 2 deprecated Pwmlatente

Dependencies:   mbed

Committer:
alejandroforero
Date:
Thu Dec 10 15:47:50 2015 +0000
Revision:
0:fd8b7f396f9c
increment and decrement of PWM in an output

Who changed what in which revision?

UserRevisionLine numberNew contents of line
alejandroforero 0:fd8b7f396f9c 1 #include "mbed.h"
alejandroforero 0:fd8b7f396f9c 2 /* view a PWM in an output with increment and decrement. anode led connected to PWM pin (8-J1 or PTA1 or D3 are equal) and cathode to ground (pin 14-J2)
alejandroforero 0:fd8b7f396f9c 3 with 330ohms resistor. */
alejandroforero 0:fd8b7f396f9c 4
alejandroforero 0:fd8b7f396f9c 5 PwmOut led (D3);
alejandroforero 0:fd8b7f396f9c 6 float value =0;
alejandroforero 0:fd8b7f396f9c 7
alejandroforero 0:fd8b7f396f9c 8 int main(){
alejandroforero 0:fd8b7f396f9c 9
alejandroforero 0:fd8b7f396f9c 10 while (true) {
alejandroforero 0:fd8b7f396f9c 11
alejandroforero 0:fd8b7f396f9c 12 for(value=0.0;value<=1.0;value+=0.02){
alejandroforero 0:fd8b7f396f9c 13 led.write(value);
alejandroforero 0:fd8b7f396f9c 14 wait(0.02);
alejandroforero 0:fd8b7f396f9c 15 }
alejandroforero 0:fd8b7f396f9c 16
alejandroforero 0:fd8b7f396f9c 17 for(value=1.0;value>=0.0;value-=0.02){
alejandroforero 0:fd8b7f396f9c 18 led = value;
alejandroforero 0:fd8b7f396f9c 19 wait(0.02);
alejandroforero 0:fd8b7f396f9c 20 }
alejandroforero 0:fd8b7f396f9c 21
alejandroforero 0:fd8b7f396f9c 22
alejandroforero 0:fd8b7f396f9c 23
alejandroforero 0:fd8b7f396f9c 24 }
alejandroforero 0:fd8b7f396f9c 25 }