Projeto Final de micro2 - controle de luminosidade via USB

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
guilhermepaulino
Date:
Mon May 16 23:09:27 2016 +0000
Commit message:
Projeto Final

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	Mon May 16 23:09:27 2016 +0000
@@ -0,0 +1,30 @@
+#include "mbed.h"
+int main(void)
+{   
+    Serial pc(USBTX, USBRX);
+    PwmOut rled(LED1);
+    PwmOut gled(LED2);
+    PwmOut bled(LED3);
+    char msg;
+    char num;
+    rled=1.0f;
+    gled=1.0f;
+    bled=1.0f;
+    while(true){
+        if(pc.readable()) {
+            msg = pc.getc();
+            num = pc.getc();
+            switch(msg){
+                case 'R': //brilho
+                    rled = 1.0f - float(num)/255.0;
+                    break;
+                case 'G':
+                    gled = 1.0f - float(num)/255.0;
+                    break;
+                case 'B':
+                    bled = 1.0f - float(num)/255.0;
+                    break;
+            }
+        }
+    }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Mon May 16 23:09:27 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/7c328cabac7e
\ No newline at end of file