Arduino Uno and Ultrasonic Distance Sensor Coding

So, forgive me if this has already been answered a thousand times, but I've found no solution for my project at hand and would really like some guidance on the topic.

My code for the UDS seems fine and works for other people's projects, but when I test it, the values on the serial monitor return 0. Since it is on tinkercad, it won't be much of a part problem thing, so I know it has something to do with my code.

define echoPin 7

define trigPin 8

long duration; long distance;

void setup() { Serial.begin(9600); pinMode(echoPin, INPUT); pinMode(trigPin, OUTPUT); }

void loop() { digitalWrite(trigPin, LOW); delayMicroseconds(2000); digitalWrite(trigPin, HIGH); delayMicroseconds(15); digitalWrite(trigPin, LOW);

duration = pulseIn(echoPin, HIGH);

//This gives us distance in cm distance = duration*58.2;

Serial.print(distance); Serial.println(" cm"); //Millisecond delay(1000); }

is the code

https://www.tinkercad.com/things/1C3KrtY8Xp7-copy-of-ultrasonic-distance-sensor-led-bar-graph-blocks/editel?tenant=circuits

is the circuit.

Do I have to include a separate code for the sensor or do I need to specify my code's print functions? I'm just very confused on how to approach this.

Which ranger so you have?

Where did you get this code?
The delays look very wrong.

So I got this code from here: https://www.youtube.com/watch?v=wCOPLVgNpcY

I was playing around with the delays, would that be the issue?

and ranger? I have an arduino uno part and ultrasonic distance sensor hc-sr04.

Ok, I’m not going to watch a video, but typically you’d pulse the trigger pin high for about 10 microseconds every 100 milliseconds or so.