receive input from terminal to control the leds
Revision 0:da915495c7fc, committed 2016-05-31
- Comitter:
- ekasinambela
- Date:
- Tue May 31 10:41:47 2016 +0000
- Commit message:
- receive input from keyboard to control the led
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 Tue May 31 10:41:47 2016 +0000
@@ -0,0 +1,25 @@
+#include "mbed.h"
+
+Serial pc(USBTX, USBRX);
+DigitalOut myled1(LED1), myled2(LED2);
+
+int main() {
+
+ while(1) {
+ char c = pc.getc();
+ if (c=='q'){
+ myled1 = 1;
+ wait(0.2);
+ myled1 = 0;
+ wait(0.2);
+ }
+
+ if (c=='w'){
+ myled2 = 1;
+ wait(0.2);
+ myled2 = 0;
+ wait(0.2);
+ }
+
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Tue May 31 10:41:47 2016 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/6c34061e7c34 \ No newline at end of file