![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Proof of concept for distance and temperature monitoring
Dependencies: mbed mbedConnectorInterface mbedEndpointNetwork
Diff: main.cpp
- Revision:
- 0:cb422b231ea5
- Child:
- 1:2d8c4995c5bc
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Fri May 01 23:21:36 2015 +0000 @@ -0,0 +1,29 @@ +#include "mbed.h" +#include "hcsr04.h" +#include "GroveTemp.h" + +#define TRIG_PIN D6 +#define ECHO_PIN D7 +#define FIRE_THRESH 32.0 + +Serial term(USBTX, USBRX); +HCSR04 distS(TRIG_PIN, ECHO_PIN); + +int main() { + GroveTempSensor tempS; + float temperature; + unsigned int distance; + + while (1) { + temperature = tempS.getTemp() * 3.0 / 5.0; + term.printf("Temp: %0.1f\n\r", temperature); + if (temperature > FIRE_THRESH) { + term.printf(" OMG! THE TRASH CAN CAN IS TOTALLY ON FIRE!!\n\r"); + } + + distS.start(); + wait_ms(500); + distance = distS.get_dist_cm(); + term.printf("Distance: %d\n\r", distance); + } +} \ No newline at end of file