Dependencies:   mbed lwip

Revision:
0:c88750da21d0
Child:
1:7354a0bac81a
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sat Sep 19 00:14:43 2009 +0000
@@ -0,0 +1,33 @@
+#include "Objects.h"
+
+/*
+ * This project used and ultrasonic range finder to blend and RGB LED from
+ * green to yellow to red as the ranged object gets closer
+ */
+
+int main() {    
+
+    while (1) {
+    
+        // Take a reading from the Ultrasonic Range Finder
+        float d = srf;
+        
+        // Scale and trim the number so it approaches 0.0 at a long range
+        // and approaches 1.0 as the range gets closer
+        float normalised = (2.0/d) - 0.02;
+        
+        // Set the red component to get brighter the closer the range
+        rgb.red(norm);
+        
+        // Set the red component to get brighter the further the range
+        rgb.green(1.0-norm);
+
+        // For completeness, print the measured range 
+        pc.printf("Range is %.1f cm\n",(float)srf);
+        wait (0.2);
+  
+    }
+
+}
+
+