PropWare  3.0.0.229
C++ objects and CMake build system for Parallax Propeller
Ping_Demo.cpp

Basic usage of the PropWare::Ping class to measure distance via an ultrasonic sensor

cmake_minimum_required(VERSION 3.12)
find_package(PropWare REQUIRED)
project(Blinky_Demo)
create_simple_executable(${PROJECT_NAME} ${PROJECT_NAME})
int main () {
const PropWare::Ping ping(Port::P14, Port::P15);
while (1) {
pwOut << "Millimeters: " << ping.get_millimeters() << '\n';
pwOut << "Centimeters: " << ping.get_centimeters() << '\n';
pwOut << "Inches: " << ping.get_inches() << '\n';
waitcnt(SECOND / 2 + CNT);
}
}
printer.h
PropWare::Ping
Ultrasonic distance sensor such as the Parallax PING)))
Definition: ping.h:54
ping.h
PropWare::Port
Flexible port that can have any pin enabled or disabled. Pins are independent of each other.
Definition: port.h:38
main
int main(void)
Definition: GraphicsTest.c:20
pwOut
PropWare::Printer pwOut
Most common use of printing in PropWare applications (not thread safe; see PropWare::pwSyncOut for mu...
waitcnt
#define waitcnt(a)
Wait until system counter reaches a value.
Definition: propeller.h:176
CNT
#define CNT
The system clock count.
Definition: propeller1.h:151
ping
int ping(int pin)
Measure echo time in terms of Propeller system clock ticks.
Definition: ping.c:3
PropWare
Generic definitions and functions for the Parallax Propeller.
Definition: runnable.h:33