first commit

Dependencies:   mbed

Committer:
t00221549
Date:
Sun Aug 08 19:40:31 2021 +0000
Revision:
0:28a7761e2484
first

Who changed what in which revision?

UserRevisionLine numberNew contents of line
t00221549 0:28a7761e2484 1 #include "mbed.h"
t00221549 0:28a7761e2484 2 Serial pc(USBTX, USBRX); // tx, rx
t00221549 0:28a7761e2484 3 PwmOut led(LED1);
t00221549 0:28a7761e2484 4 float brightness = 0.0;
t00221549 0:28a7761e2484 5 int main()
t00221549 0:28a7761e2484 6 {
t00221549 0:28a7761e2484 7 pc.printf("Press 'u' to turn LED1 brightness up, 'd' to turn it down \r\n");
t00221549 0:28a7761e2484 8 while(1) {
t00221549 0:28a7761e2484 9 char c = pc.getc();
t00221549 0:28a7761e2484 10 if((c == 'u') && (brightness < 0.5)) {
t00221549 0:28a7761e2484 11 pc.putc('^');
t00221549 0:28a7761e2484 12 brightness += 0.01;
t00221549 0:28a7761e2484 13 led = brightness;
t00221549 0:28a7761e2484 14 }
t00221549 0:28a7761e2484 15 if((c == 'd') && (brightness > 0.0)) {
t00221549 0:28a7761e2484 16 pc.putc('v');
t00221549 0:28a7761e2484 17 brightness -= 0.01;
t00221549 0:28a7761e2484 18 led = brightness;
t00221549 0:28a7761e2484 19 }
t00221549 0:28a7761e2484 20 }
t00221549 0:28a7761e2484 21 }