ultrasonic sensors for roboticized zuca project
Dependencies: HC_SR04_Ultrasonic_Library mbed
Fork of Nucleo_UltrasonicHelloWorld by
Revision 2:1673deaeefad, committed 2017-07-21
- Comitter:
- Abraxas3d
- Date:
- Fri Jul 21 17:46:29 2017 +0000
- Parent:
- 1:4a5586eb1765
- Child:
- 3:d0e45e12a03f
- Commit message:
- Initial bit of code for ultrasonic detection for Robotized Zuca.
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Thu Dec 04 08:04:55 2014 +0000
+++ b/main.cpp Fri Jul 21 17:46:29 2017 +0000
@@ -1,19 +1,27 @@
#include "mbed.h"
#include "ultrasonic.h"
+Serial pc(USBTX, USBRX); // tx, rx
+
void dist(int distance)
{
//put code here to happen when the distance is changed
- printf("Distance changed to %dmm\r\n", distance);
+ pc.printf("Distance changed to %dmm\r\n", distance);
+ //pc.printf("Distance changed!\n");
+ //printf("Distance changed!\r\n");
}
-ultrasonic mu(D8, D9, .1, 1, &dist); //Set the trigger pin to D8 and the echo pin to D9
+//ultrasonic mu(D8, D9, .1, 1, &dist); //Set the trigger pin to D8 and the echo pin to D9
+ //have updates every .1 seconds and a timeout after 1
+ //second, and call dist when the distance changes
+
+ultrasonic mu(p30, p29, .1, 1, &dist); //Set the trigger pin to D30 and the echo pin to D29
//have updates every .1 seconds and a timeout after 1
//second, and call dist when the distance changes
int main()
{
- mu.startUpdates();//start mesuring the distance
+ mu.startUpdates();//start measuring the distance
while(1)
{
//Do something else here
Cat Teacup
