Sonar demo with timer interrupts
Dependencies: HC_SR04_Ultrasonic_Library mbed
Fork of Nucleo_UltrasonicHelloWorld by
Revision 0:1704ea055c4f, committed 2014-11-23
- Comitter:
- ejteb
- Date:
- Sun Nov 23 20:27:21 2014 +0000
- Child:
- 1:4a5586eb1765
- Commit message:
- seems to work :0
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/HC_SR04_Ultrasonic_Library.lib Sun Nov 23 20:27:21 2014 +0000 @@ -0,0 +1,1 @@ +HC_SR04_Ultrasonic_Library#6aa04a8c8d4c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sun Nov 23 20:27:21 2014 +0000 @@ -0,0 +1,41 @@ +#include "mbed.h" +#include "ultrasonic.h" + +//time_t startTime; +//Timer t; +//float s; + void dist(int distance) +{ + //float new_s; + //new_s = t.read (); + //printf("I think %f s passed, current time %f, %f\r\n", (double)(new_s-s), new_s, s); + //printf("distance updated %d\r\n", distance); + //printf("RTC clock says %d\r\n", (time(NULL)-startTime)); +} +void startTimer() +{ + //s = t.read(); + //printf("timer started \r\n"); + //startTime = time(NULL); +} +void trigger() +{ + //printf("trigger sent\r\n"); +} + +ultrasonic mu(D8, D9, 1, 2, &dist, &trigger, &startTimer); + +int main() +{ + //t.start(); + mu.startUpdates(); + while(1) + { + //Do something else + //printf("doing something"); + if(mu.isUpdated()) + { + printf("Distance = %d\r\n", mu.getCurrentDistance()); + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Sun Nov 23 20:27:21 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/031413cf7a89 \ No newline at end of file