lab

Dependencies:   mbed C12832

Revision:
0:94dcb8c6ed26
Child:
1:2e8c02d29418
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sat Jul 18 08:59:16 2020 +0000
@@ -0,0 +1,20 @@
+#include "mbed.h"
+Serial pc(USBTX, USBRX); // tx, rx
+PwmOut led(LED1);
+float brightness = 0.0;
+int main() {
+ pc.printf("Press 'u' to turn LED1 brightness up, 'd' to turn it down\n");
+ while(1) {
+ char c = pc.getc();
+ if((c == 'u') && (brightness < 0.5)) {
+ brightness += 0.01;
+ led = brightness;
+ pc.putc('^');// using "^" for LED brightness up 
+ }
+ if((c == 'd') && (brightness > 0.0)) {
+ brightness -= 0.01;
+ led = brightness;
+ pc.putc('&&');//using "&&" for down LED brightness down
+ }
+ }
+}
\ No newline at end of file