A sample heatmap application on using the red and green LEDs and input from a temperature sensor

Dependencies:   DS1820 mbed

Files at this revision

API Documentation at this revision

Comitter:
gkroussos
Date:
Fri Jul 11 23:43:12 2014 +0000
Child:
1:cc10d171a883
Commit message:
Initial heatmap release for Bloomsbury Hack Day

Changed in this revision

DS1820.lib Show annotated file Show diff for this revision Revisions of this file
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/DS1820.lib	Fri Jul 11 23:43:12 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/Sissors/code/DS1820/#d87e11e8d012
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Jul 11 23:43:12 2014 +0000
@@ -0,0 +1,33 @@
+#include "mbed.h"
+#include "DS1820.h"
+
+#define DATA_PIN        D13
+#define minTemp  25.5
+#define maxTemp  30.0
+
+
+DS1820 probe(DATA_PIN);
+
+PwmOut red(LED_RED);
+PwmOut green(LED_GREEN);
+
+int main() {
+    float p = 0.0;
+    red.period(0.001);
+    
+    for (float i=0.0; i<1.0; i+= 0.25) { 
+       green = i;
+       red = 1.0-i;
+       wait(2.0);
+    }
+    
+    while (true) {
+        probe.convertTemperature(true, DS1820::all_devices);         //Start temperature conversion, wait until ready
+        printf("It is %3.1foC\r\n", probe.temperature());
+        p = (probe.temperature() - minTemp) / (maxTemp - minTemp);
+        printf("LED Value %f\r\n", p);
+        green = p;
+        red = 1.0 -p;
+        wait (.5);
+    }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Fri Jul 11 23:43:12 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/04dd9b1680ae
\ No newline at end of file