Defines | Functions | Variables
sonar.cpp File Reference
#include <NewPing.h>
#include <sonar.h>
Include dependency graph for sonar.cpp:

Go to the source code of this file.

Defines

#define MAX_DISTANCE   200
 maximum distance to ping (cm)
#define N_SONARS   3
 number of sonars

Functions

void timer_event ()

Variables

static NewPing sonar [N_SONARS]
static uint8_t static_current = N_SONARS
 currently active sonar
static unsigned int static_distance
 distance of current ping

Detailed Description

Sonar implementation for Segbot version 2.

This program is driven by timer events. On a 30Hz cycle, it sends any previous results in a serial message, then pings the next sonar in a round-robin fashion.

Definition in file sonar.cpp.


Define Documentation

#define MAX_DISTANCE   200

maximum distance to ping (cm)

Definition at line 48 of file sonar.cpp.

#define N_SONARS   3

number of sonars

Definition at line 49 of file sonar.cpp.


Function Documentation

void timer_event ( )

Timer interrupt handler.

If ping has completed, set the current distance.

This should be a class member function, but it is static because the NewPing and Arduino timer interfaces only allow static functions.

Definition at line 73 of file sonar.cpp.


Variable Documentation

NewPing sonar[N_SONARS] [static]
Initial value:
  {
    NewPing(30, 4, MAX_DISTANCE),
    NewPing(28, 3, MAX_DISTANCE),
    NewPing(26, 2, MAX_DISTANCE),
  }

Each sonar with trigger pin, echo pin, and max distance.

Definition at line 52 of file sonar.cpp.

uint8_t static_current = N_SONARS [static]

currently active sonar

Definition at line 62 of file sonar.cpp.

unsigned int static_distance [static]

distance of current ping

Definition at line 63 of file sonar.cpp.



segbot_firmware
Author(s): Jose Bigio, Jack O'Quin, Tim Eckel (NewPing library)
autogenerated on Fri Aug 28 2015 13:02:53