Hello, I need help with this, if anyone knows the code and how to do it on the breadboard I would be grateful

What kind of distance are you talking about?

I would first get an HC-SR04 sensor working on your UNO. With one of the example programs have the distance read by the sensor printed to the IDE serial monitor. Move things around and see is the sensor results follow what you are looking for. As @runaway_pancake said, the readings can seem to be very random at times and depending on the moving "target"