HC-06 Bluetooth Code Help (Brand New To Arduino)

Hello
I am working on created the code for a device for a school project.
I would like for it to connect and lock two HC-06 modules together, read the distance between them, and emit a sound based on that distance. I have bits of the that already, mainly the connecting part and the speaker, but I do not know how to get it to read the distance and to report it back.
Any help would be much appreciated.
Thank you
EDD Group 11

but I do not know how to get it to read the distance

The devices haven't a clue how far apart they are. They are either in range, or they aren't. So, it's really no wonder you haven't been able to get them to tell you how far apart they are.

Forget it. HC-06s are slave-only devices, you will never make a connection between them, and they will never tell you anything.. I would also suggest you also resist any temptation to swap out an HC-06 for an HC-05, which is a master, and can connect to an HC-06, but this is still a dumb idea.

I understand you might, just might, get some sort of result using BLE modules. Apparently, they have something more sophisticated in the RSSI department, which is where I believe your wishful thinking lies. This might give you an audible indication of how much money and time you have wasted - particularly if you have already bought the HC-06s.

Try and think of something more useful. The HC-06 is a very useful but rather ordinary device that serves no more purpose than as a replacement for a wired connection, without adding any extra flavour of its own.

You might find the following background notes useful.

http://homepages.ihug.com.au/~npyner/Arduino/GUIDE_2BT.pdf
http://homepages.ihug.com.au/~npyner/Arduino/BT_2_WAY.ino

Thanks for your response.
I made a mistake, I thought that we were using HC-06 when we were actually using HC-05.
Would that make a difference or would it make no difference.
Thanks
EDD Group 11

The short answer is you cannot do what you want with the equipment you have. Bluetooth radios have what's called a received signal strength indicator (RSSI) that will give you a guess at how far away they are but you have no access to that value with a HC module, which is only meant to pass data as with a serial connection.

If I was in Group 11 I would consider what sensors I had access to and try to be creative. For example, putting light sensors on the sending and receiving Arduinos would let you know the difference in light level in the locations of the two units.

Good luck with your project.