Proximity Sensor which works on Infrared wavelength is really inexpensive yet reliable way to measure the close distance without physical contact, nowadays, they are also used as non contact limit switches in CNC and 3D printers for the fact that they have really less interference and they do not have to be in physical contact or contain any mechanical moving part which makes them really reliable.
Commonly a certain threshold value from the sensor is defined, so the sensor whenever reads the values closer or farther, the Arduino can be programmed to do certain tasks.
Infrared Proximity Sensor could be used in a wide variety of applications commercially, on of them being the reverse parking distance sensor, so if you have any old car lying around which does not indicate the distance, you can make use of the proximity sensor to add depth sensing functionality on your own!
Enough Talk! Let's Build!
Following is the video tutorial if you would prefer watching and learning.Step 1: Things Needed
IR Sensor (I am using a pretty generic IR sensor which is easily available everywhere)
Arduino (I am using Arduino Nano)
USB for Arduino
Arduino IDE installed on a computerStep 2: Connect the Proximity Sensor to Arduino
Make a connection to IR sensor to Arduino in the following way:
Vcc -- 5V
OUT -- A0Step 3: Connect HC-06 Bluetooth Module to Arduino
Connect the Bluetooth Module HC-06 to Arduino in the following way:
Gnd -- GndStep 4: Download the Code and Upload
Download the code from this link, the link will take you to MediaFire page which will contain a folder named 'IR_Sensor'.
The folder will contain the "IR_Sensor.ino" file, this is the main code that should be uploaded.
Select your Board and COM port of the Arduino and upload it.Step 5: Download the Serial Monitor App
This is a generic Android application which acts as a serial monitor via Bluetooth, you can find similar apps on IOS.
Just go to the connect button and click the HC-06 to get connected.Step 6: Done!
After Pairing and connecting the Bluetooth Module to the app, you would easily be able to read the data which measures the distance between the object and sensor, once the distance is less than a certain threshold the output is 0 and 255 otherwise.
Here 1 means close to 255 and 0 is close to 0. (8-bit value mapping in code.)
Thank You So Much For Reading!