abc
Dependencies: mbed Servo HC_SR04_Ultrasonic_Library
Revision 0:fa67d6421193, committed 2019-03-05
- Comitter:
- kociol1994
- Date:
- Tue Mar 05 10:13:44 2019 +0000
- Commit message:
- Ana
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/HC_SR04_Ultrasonic_Library.lib Tue Mar 05 10:13:44 2019 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/users/ejteb/code/HC_SR04_Ultrasonic_Library/#e0f9c9fb4cf3
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Servo.lib Tue Mar 05 10:13:44 2019 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/simon/code/Servo/#36b69a7ced07
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue Mar 05 10:13:44 2019 +0000 @@ -0,0 +1,39 @@ +#include "mbed.h" +#include "Servo.h" +#include "ultrasonic.h" + + +void dist(int distance) +{ + //put code here to execute when the distance has changed + printf("Distance %d mm\r\n", distance); +} + +Servo myservo(D9); +Serial pc(SERIAL_TX, SERIAL_RX); + +ultrasonic mu(D8, D10, .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 + +//------------------------------------------------------------------------------------------------- + int main() { + + myservo.calibrate (0.001, 45.0); // kalibracja serva + mu.startUpdates(); //start measuring the distance + + while(1) { + for(int i=(-25); i<35; i++) { + myservo.position(i); + wait(0.5); + printf("Pozycja %d ", i); + mu.checkDistance(); + } + for(int i=35; i>(-25); i--) { + myservo.position(i); + wait(0.5); + printf("Pozycja %d ", i); + mu.checkDistance(); + } + } + } \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Tue Mar 05 10:13:44 2019 +0000 @@ -0,0 +1,1 @@ +https://mbed.org/users/mbed_official/code/mbed/builds/86740a56073b \ No newline at end of file