George Roussos
/
heatmap
A sample heatmap application on using the red and green LEDs and input from a temperature sensor
main.cpp
- Committer:
- gkroussos
- Date:
- 2014-07-11
- Revision:
- 0:f3a63f2e3746
- Child:
- 1:cc10d171a883
File content as of revision 0:f3a63f2e3746:
#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); } }