Multiple sensor reading (digital pin as vcc and ground)

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() {

}  

@Rajasingh please edit your post, using the pencil icon at the bottom, and add triple backticks at the beginning and end of your code so that it displays correctly.
Triple backticks look like this:
```

Copy and paste these characters if you can’t find the correct character on your keyboard.

Pete.

Done sir,
Happy blynking