Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: HCSR04v2 Servo mbed
Fork of STM_read by
Revision 2:26a9f90142a0, committed 2016-06-21
- Comitter:
- yruiewyrui3
- Date:
- Tue Jun 21 09:19:17 2016 +0000
- Parent:
- 1:b57f208d1d95
- Child:
- 3:1a391dd91a35
- Commit message:
- .
Changed in this revision
| HCSR04.lib | Show annotated file Show diff for this revision Revisions of this file |
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/HCSR04.lib Tue Jun 21 07:46:37 2016 +0000 +++ b/HCSR04.lib Tue Jun 21 09:19:17 2016 +0000 @@ -1,1 +1,1 @@ -https://developer.mbed.org/users/yruiewyrui3/code/HCSR04/#0b3bdb910fe7 +https://developer.mbed.org/users/yruiewyrui3/code/HCSR04v2/#8c633a86ddb5
--- a/main.cpp Tue Jun 21 07:46:37 2016 +0000
+++ b/main.cpp Tue Jun 21 09:19:17 2016 +0000
@@ -23,7 +23,8 @@
int po=0;
int pi=0;
Timer t, t_sonar;
-float distance;
+long distance;
+
//*************** Funkcja czyszczaca bufor *****************
void cleanBuffer(char *buffor)
@@ -146,17 +147,18 @@
int i = 0;
cleanBuffer(bufor);
stm.baud(115200);
+ t_sonar.start();
while(true){
if(t.read_ms()>200){ //jesli przez ponad 200ms nie ma nowej ramki, zatrzymujemy robota
eng_left.move(0);
eng_right.move(0);
}
if(t_sonar.read_ms()>1200){
+ distance = sensor.distance();
+ stm.printf("dystans %d \n",distance);
t_sonar.stop();
t_sonar.reset();
t_sonar.start();
- distance = sensor.distance();
- stm.printf("dystans %d \n",distance);
}
if(bufor[9] == NULL){
bufor[i] = stm.getc();
