The Nucleo Distance Calculator Simple code to use HCSR04 and nokia 5110 to display distance and ring a buzzer when the distance is lower than a certain threshold.
Dependencies: N5110 NOKIA_5110 mbed
Fork of UltraTest by
main.cpp
- Committer:
- srsmitherman
- Date:
- 2014-03-11
- Revision:
- 0:f91b4b2acbe1
- Child:
- 1:56e6200a897b
File content as of revision 0:f91b4b2acbe1:
#include "mbed.h" #include "HCSR04.h" DigitalOut myled(LED1); Serial pc(USBTX,USBRX); HCSR04 ultra(p12,p11); float range=0; int main() { pc.printf("Program Start\n"); while(1) { ultra.startMeas(); wait(0.2); if( ultra.getMeas(range) == RANGE_MEAS_VALID) { pc.printf("Range - %f\n\r", range); } } }