When we connect more than 1 sensor in a single vcc and ground… The reading will show wrong details. So we can solve this by converting any digital pin to gnd and vcc using the below program
you can just try converting two digital pins as 5V vcc and ground. this will be usefull when we use multiple sensors
#define VCC2 5 // define pin 5 or any other digial pin here as VCC2
#define GND2 2 // define pin 2 or any other digital pin as Ground 2
void setup() {
pinMode(VCC2,OUTPUT);//define a digital pin as output digitalWrite(VCC2, HIGH);// set the above pin as HIGH so it acts as 5V
pinMode(GND2,OUTPUT);//define a digital pin as output digitalWrite(GND2, LOW);// set the above pin as LOW so it acts as Ground
}
void loop() {
}