Mjerenje napona - 03.11

Dependencies:   mbed

Fork of VT1_Pervan by Applied engineering Team

Committer:
fpervan
Date:
Thu Nov 10 19:02:06 2016 +0000
Revision:
3:30a434029ace
Parent:
2:9d203ce835e8
Child:
4:01e6c90b206d
pojacavanje i smanjivanje LED

Who changed what in which revision?

UserRevisionLine numberNew contents of line
fpervan 3:30a434029ace 1 // host terminal LED dimmer control
fpervan 2:9d203ce835e8 2 #include "mbed.h"
fpervan 3:30a434029ace 3 Serial pc(USBTX, USBRX); // tx, rx
fpervan 3:30a434029ace 4 PwmOut PWM1(p21);
fpervan 3:30a434029ace 5 float brightness=0.0;
fpervan 2:9d203ce835e8 6 int main() {
fpervan 3:30a434029ace 7 PWM1.period(0.010); // set PWM period to 10 ms
fpervan 3:30a434029ace 8 PWM1=0.8; // set duty cycle to 80%
fpervan 3:30a434029ace 9 pc.printf("Control of LED dimmer by host terminal\n\r");
fpervan 3:30a434029ace 10 pc.printf("Press 'u' = brighter, 'd' = dimmer\n\r");
fpervan 3:30a434029ace 11 while(1) {
fpervan 3:30a434029ace 12 char c = pc.getc();
fpervan 3:30a434029ace 13 wait(0.001);
fpervan 3:30a434029ace 14 if((c == 'u') && (brightness < 1.0)) {
fpervan 3:30a434029ace 15 brightness += 0.1;
fpervan 3:30a434029ace 16 PWM1= brightness;
fpervan 3:30a434029ace 17 }
fpervan 3:30a434029ace 18 if((c == 'd') && (brightness > 0.0)) {
fpervan 3:30a434029ace 19 brightness -= 0.1;
fpervan 3:30a434029ace 20 PWM1= brightness;
fpervan 3:30a434029ace 21 }
fpervan 3:30a434029ace 22 pc.printf("%c %1.3f \n \r",c,brightness);
fpervan 2:9d203ce835e8 23 }
fpervan 2:9d203ce835e8 24 }