Felix Pachay
/
Tutoria_Pachay
Intensidad_Led
Revision 0:5248e12b2868, committed 2020-02-08
- Comitter:
- fpachays
- Date:
- Sat Feb 08 02:48:22 2020 +0000
- Commit message:
- UPS_Maestria_pwm
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 |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sat Feb 08 02:48:22 2020 +0000 @@ -0,0 +1,26 @@ +#include "mbed.h" +Serial pc(PA_2, PA_3,115200); //tx, rx +PwmOut led(PA_0); +float brightness=0.0; + +int main() +{ + 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)) { + brightness += 0.1; + motor= brightness; + } + if(( c == 'd') && (brightness > 0)) { + brightness -= 0.1; + motor = brightness; + } + + pc.printf("%c %1.3f \n \r",c,brightness); + + } +} +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Sat Feb 08 02:48:22 2020 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400 \ No newline at end of file