The task
In this project, I connected a 2YA21 Sharp Infrared Proximity sensor to an Arduino to test the functionality of the sensor.
I was primarily aided by a tutorial on bildr, which was incredibly helpful. It provided both the schematic and code that I used.
The materials I began with were an Arduino and the 2YA21 sensor, shown below.
Because the wires of the sensor were stranded, and I anticipated needing to use solid core wires to connect the sensor to the Arduino, I stripped the wires, and soldered each wire to solid core wire of corresponding colors, and covered the connection with electrical tape to avoid a short circuit if they touched.
Once the connections to solid core wires were made, I pulled the sensor into the Arduino (schematic attached), which I had already loaded the analog read code onto (also attached to this page).
Next, using the serial monitor, I tracked the read out of the sensor, in gauging how close a box (and my phone and hand) was to the sensor.
The process was generally straightforward, and I didn't face any problems.
Here were my results from positioning the box at 20, 40, 60, and 80cm away from the sensor (the results did fluctuate to a degree, but these were the numbers that the serial monitor tended to settle on):
20cm: 266
40cm: 155
60cm: 105
80cm: 82
At about 4 cm, the analog read peaked at about 653, and decreased as the box got even closer. The effective operation range was about 90cm away, after which the sensor no longer gave reliable.
Comments