![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
asdf
Dependencies: Servo mbed mbedConnectorInterface mbedEndpointNetwork
Fork of TempAndDistTest by
main.cpp
- Committer:
- Luminoscity
- Date:
- 2015-05-01
- Revision:
- 0:cb422b231ea5
- Child:
- 1:2d8c4995c5bc
File content as of revision 0:cb422b231ea5:
#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); } }