
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 | |
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 MAX_DISTANCE 200 |
| void timer_event | ( | ) |
{
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.
uint8_t static_current = N_SONARS [static] |
unsigned int static_distance [static] |