Detecting distance between bikes and vehicles and vehicle speed

Hi everyone,

I am doing project on detecting the distance between bikes and vehicles with using Ping sensor & arduino UNO What I have done so far is detecting any object passing Ping sensor and tracking the object until it is disappeared and it is displayed on Serial monitor in the program. which gives the following results (as an samples):

1 car detected at 6cm. time_count = 1
2 car detected at 5cm. time_count = 1
3 car detected at 20cm. time_count = 1
4 car detected at 8cm. time_count = 1
5 car detected at 4cm. time_count = 8
6 car detected at 4cm. time_count = 6
7 car detected at 26cm. time_count = 5
8 car detected at 32cm. time_count = 5
9 car detected at 88cm. time_count = 2
10 car detected at 79cm. time_count = 1
11 car detected at 75cm. time_count = 3
12 car detected at 96cm. time_count = 1
13 car detected at 87cm. time_count = 1

My question is on the following things:
1- How can I extend the length of distance to up to 300 cm? where I the it is only detect up to 100 cm (by noting that Ping sensor can detect up to 313 cm)
2- How can I store the data from the Arduino board? which can store the data in the journey, then plug the arduino to the PC and get the result taken during the journey
3-How to sample distance over time during the journey.

Please, what changes I need to do?

I attached the code I have so far.

Thanks

Ping.ino (2.25 KB)

Post the datasheet (or vendor link) for your sensor.

Here is the datasheet of the sensor

Ping sensor.pdf (164 KB)

Ping sensor_+1.pdf (383 KB)

Datasheet says it can detect up to just over 3 yds.
I couldn't answer your question unless you posted your code and even then someone else may have to answer it. Without your code we can't help I don't see any config options. You just send a ping and read the return echo. Read the datasheet again and see if you can figure that out.

I sent the code in the first message
Here it is again

Ping.ino (2.25 KB)

I think the problem is in your code. Google arduino ping example code .
I'm working right now. Can't help.

I assume you have altered the below line?

int threshold_distance = 100;//313; // a car is detected when distance is less than this threshold

You may need to just print out the distance value with nothing in front of it a few times to get an idea of the threshold value you need to set so you don't get false readings.