PropWare
3.0.0.229
C++ objects and CMake build system for Parallax Propeller
Simple-Libraries
Learn
Examples
Robots
Arlo
Arlo - Test Ping Array.c
1
/*
2
Arlo - Test Ping Array.c
3
*/
4
5
#include "
simpletools.h
"
6
#include "ping.h"
7
8
int
n = 0, pingPin, cmDist;
9
int
pins[4] = {14, 16, 17, 15};
10
11
int
main
()
12
{
13
while
(1)
14
{
15
if
(n == 0)
16
{
17
print
(
"%c"
,
HOME
);
18
print
(
"Ping))) Distances\n"
);
19
print
(
"-----------------\n"
);
20
}
21
22
pingPin = pins[n];
23
cmDist =
ping_cm
(pingPin);
24
25
switch
(pingPin)
26
{
27
case
14:
print
(
"Front: "
);
break
;
28
case
16:
print
(
"Left: "
);
break
;
29
case
17:
print
(
"Right: "
);
break
;
30
case
15:
print
(
"Back: "
);
break
;
31
}
32
33
print
(
"%03d cm\n"
, cmDist);
34
n++;
35
if
(n >= 4) n =0;
36
pause
(200);
37
}
38
}
ping_cm
int ping_cm(int pin)
Report Ping))) measurement as a centimeter distance.
Definition:
ping.c:11
HOME
#define HOME
HOME character (1) sends SimpleIDE Terminal's cursor to top-left "home" position.
Definition:
simpletools.h:233
pause
void pause(int time)
Delay cog from moving on to the next statement for a certain length of time.
Definition:
libws2812.c:125
simpletools.h
This library provides convenient functions for a variety of microcontroller I/O, timing,...
print
int print(const char *format,...) __attribute__((format(printf
Print format "..." args to the default simple terminal device. The output is limited to 256 bytes.
main
int main(void)
Definition:
GraphicsTest.c:20
Generated on Fri May 20 2022 16:48:04 for PropWare by
1.8.17