endpoint including temperature and distance sensors

Dependencies:   mbed mbedConnectorInterface mbedEndpointNetwork TrashSensors

Fork of TempAndDistTest by Tim Ambrose

main.cpp

Committer:
coyotebush
Date:
2015-05-01
Revision:
1:2d8c4995c5bc
Parent:
0:cb422b231ea5
Child:
2:b51fcb5fd114

File content as of revision 1:2d8c4995c5bc:

#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); 

// Corey was here
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);
   }
}