Igor Padjen
/
v5_2_upravljanje_LEDdioda
upravljanje_LED x50%
Revision 0:b534566a0c77, committed 2015-12-10
- Comitter:
- ipadjen
- Date:
- Thu Dec 10 17:38:22 2015 +0000
- Commit message:
- Uprav_LED osvjetljenjem_x50%
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
diff -r 000000000000 -r b534566a0c77 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu Dec 10 17:38:22 2015 +0000 @@ -0,0 +1,30 @@ +// host terminal LED dimmer control +#include "mbed.h" +Serial pc(USBTX, USBRX); // tx, rx +PwmOut PWM1(p21); +float brightness=0.0; +int main() +{ + PWM1.period(0.010); // set PWM period to 10 ms + PWM1=0.8; // set duty cycle to 80% + pc.printf("Control of LED dimmer by host terminal\n\r"); + pc.printf("Press 'u' = brighter, 'd' = dimmer\n\r"); + while(1) { + char c = pc.getc(); + wait(0.001); + if((c == 'u') && (brightness < 1.0)) { + brightness += 0.1; + PWM1= brightness; + } + if((c == 'd') && (brightness > 0.0)) { + brightness -= 0.1; + PWM1= brightness; + } + if(c=='x') { + brightness = 0.5; + PWM1= brightness; + } + + pc.printf("%c %1.3f \n \r",c,brightness); +} +}
diff -r 000000000000 -r b534566a0c77 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Thu Dec 10 17:38:22 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/165afa46840b \ No newline at end of file