Need some help on a ultrasonic sensor problem

Time to look at the circuit. Somewhere there is a ground missing or you are picking up (electrical) noise. If you have schematics fine, but a phone-snap ofa handdrawn one can do. Also perhaps a picture of the physical setup, particular the problematic power supply wiring.

The Arduino either needs the USB or 5V regulated, clean on the VIN pin, or 7v to 12V on the barreljack (where it goes through the onboard regulator). You wrote 6V ... which goes where?

I did not see the setup for the ultrosonic sensors in your code. How are you reading them (analog or I2C or SPI ...). Analog pins are default input, which may start explaining your difficulty - the analog read needs a reference and if you do not have the correct supply voltage it will derive the wrong reference from VIN.