wef

Dependencies:   mbed

Revision:
8:4bed841036f9
Parent:
7:ad8295723268
--- a/main.cpp	Wed Jul 16 10:20:45 2014 +0000
+++ b/main.cpp	Tue Oct 11 21:19:03 2022 +0000
@@ -2,18 +2,30 @@
 
 PwmOut r(LED_RED);
 PwmOut g(LED_GREEN);
+Serial pc(USBTX, USBRX);
+
+void RX_handler(void);
 
 int main()
 {
     r.period(0.001f);
     g.period(0.001f);
 
-    while (true) {
-        for (float i = 0.0f; i < 1.0f ; i += 0.001f) {
-            float p = 3 * i;
-            r = 1.0f - ((p < 1.0f) ? 1.0f - p : (p > 2.0f) ? p - 2.0f : 0.0f);
-            g = 1.0f - ((p < 1.0f) ? p : (p > 2.0f) ? 0.0f : 2.0f - p);
-            wait (0.0025f);
-        }
+    r = 1;
+    g = 1;
+    
+    pc.attach(&RX_handler);
+    
+    while(1)
+    {
+        wait(0.2);
     }
 }
+
+void RX_handler(void)
+{
+    while(pc.readable())
+    {
+        pc.putc(pc.getc());
+    }
+}
\ No newline at end of file