PropWare
3.0.0.229
C++ objects and CMake build system for Parallax Propeller
Simple-Libraries
Learn
Examples
Robots
ActivityBot
Test Ping.c
1
/*
2
Test Ping.c
3
4
Test the PING))) sensor before using it to navigate with the ActivityBot.
5
6
http://learn.parallax.com/activitybot/build-and-test-ping-sensor-circuit
7
*/
8
9
#include "
simpletools.h
"
// Include simpletools header
10
#include "ping.h"
// Include ping header
11
12
int
distance;
// Declare distance variable
13
14
int
main
()
// main function
15
{
16
while
(1)
// Repeat indefinitely
17
{
18
distance =
ping_cm
(8);
// Get cm distance from Ping)))
19
20
print
(
"%c distance = %d%c cm"
,
// Display distance
21
HOME
, distance,
CLREOL
);
22
23
pause
(200);
// Wait 1/5 second
24
}
25
}
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
CLREOL
#define CLREOL
CLREOL character (11) erases all SimpleIDE Terminal characters to the right of the cursor.
Definition:
simpletools.h:323
Generated on Fri May 20 2022 16:48:04 for PropWare by
1.8.17