This connection diagram (below) shows where to connect each 3-wire Ping))) sensor cable. If you’re looking at the color version, note that each black wire is connected to either GND on the breadboard, or the GND terminal in the servo header. Each of those black wires should also be connected to a Ping))) sensor’s GND pin. The power selection jumper between the P13 and P14 servo ports should also be set to 5V, likewise for the one between P15 and P16.
WARNING: Wiring errors can damage the Ping))) sensors and/or your Propeller. Do not turn power back on until you have double-checked all the connections in this section’s checklist below.
The SimpleIDE Terminal display after connecting the Ping))) sensors and running the example program will resemble this. If all the Ping))) sensors are connected correctly, the display should show the centimeter distances of obstacles placed in front of each one (within its 3 cm to 3 m range, and typically +/- 1 cm). Note that right now, the right Ping))) sensor does not see an obstacle, either because it’s beyond the 3 m limit, or the obstacle might be at an angle that’s reflecting the ultrasonic energy away from (instead of back to) the sensor. If you put your hand about 10 cm in front of the right sensor, that value should change to about 10. Make sure that each sensor correctly reports distances when you do that.
/* Arlo - Test Ping Array.c */ #include "simpletools.h" #include "ping.h" int n = 0, pingPin, cmDist; int pins[4] = {14, 16, 17, 15}; int main() { while(1) { if(n == 0) { print("%c", HOME); print("Ping))) Distances\n"); print("-----------------\n"); } pingPin = pins[n]; cmDist = ping_cm(pingPin); switch(pingPin) { case 14: print("Front: "); break; case 16: print("Left: "); break; case 17: print("Right: "); break; case 15: print("Back: "); break; } print("%03d cm\n", cmDist); n++; if(n >= 4) n =0; pause(200); } }