To do this, connect the additional pins, as follows:
Arduino pin | Sensor pin |
5V | Sensor 1 VCC |
GND | Sensor 1 GND |
12 | Sensor 1 Trig |
11 | Sensor 1 Echo |
5V | Sensor 2 VCC |
GND | Sensor 2 GND |
10 | Sensor 2 Trig |
9 | Sensor 2 Echo |
5V | Sensor 3 VCC |
GND | Sensor 3 GND |
8 | Sensor 3 Trig |
7 | Sensor 3 Echo |
Here is a picture of the three sensors assembled:
Now that the sensors are connected, you'll need to add some functionality to the Arduino code to communicate with all three sensors. Here is that Arduino code:
#include <NewPing.h>
#define TRIGGER_PIN1 12
#define ECHO_PIN1 11
#define TRIGGER_PIN2 10#define ECHO_PIN2 9
#define TRIGGER_PIN3 8
#define ECHO_PIN3 7
#define MAX_DISTANCE 200
NewPing sonar1(TRIGGER_PIN1, ECHO_PIN1, MAX_DISTANCE);
NewPing sonar2(TRIGGER_PIN2, ECHO_PIN2, MAX_DISTANCE);
NewPing sonar3(TRIGGER_PIN3...