How to Make a Simple Proximity Sensor Using Arduino

Start off by setting aside the required materials; , Prepare the IR LED by cutting a small piece of the electric tape and then wrapping it around the LED to form a tube as shown above. , Using the breadboard, jumper wires, resistor & LED's set up...

8 Steps 1 min read Medium

Step-by-Step Guide

  1. Step 1: Start off by setting aside the required materials;

    Connect the resistor from 5v to the positive( big pin) on the IR receiver.

    Connect all the IR LEDs to the
    3.3v pin on the Arduino.

    Connect a jumper from A0 on the Arduino to the positive leg on the IR receiver.

    Connect all of the negatives of both the receiver and the LEDs to the GND on Arduino.

    Make sure none of the wires or LEDs are shorting as LEDs are very sensitive and can burn. , This is a simple code that will print out the IR data on your computer screen, these variables can then be used to control almost anything.

    This code will allow for a simple analog read of the IR sensor. int IRreceiver = A0; // initialize int IRval; void setup() { pinMode(IRreceiver, INPUT); // declare its an input Serial.begin(9600); // speed at which the communication will happen } void loop() { int IRval= analogRead(IRreceiver); // declare data Serial.println(IRval); // print the data delay(10); } // add a delay to smoothen things out , After it's uploaded bring up the serial communication., The data should vary as the distance between the sensor and the object varies.
  2. Step 2: Prepare the IR LED by cutting a small piece of the electric tape and then wrapping it around the LED to form a tube as shown above.

  3. Step 3: Using the breadboard

  4. Step 4: jumper wires

  5. Step 5: resistor & LED's set up connection as follows.

  6. Step 6: Build your code.

  7. Step 7: Make sure all the connections are safe and then upload the code to your Arduino.

  8. Step 8: Examine the data.

Detailed Guide

Connect the resistor from 5v to the positive( big pin) on the IR receiver.

Connect all the IR LEDs to the
3.3v pin on the Arduino.

Connect a jumper from A0 on the Arduino to the positive leg on the IR receiver.

Connect all of the negatives of both the receiver and the LEDs to the GND on Arduino.

Make sure none of the wires or LEDs are shorting as LEDs are very sensitive and can burn. , This is a simple code that will print out the IR data on your computer screen, these variables can then be used to control almost anything.

This code will allow for a simple analog read of the IR sensor. int IRreceiver = A0; // initialize int IRval; void setup() { pinMode(IRreceiver, INPUT); // declare its an input Serial.begin(9600); // speed at which the communication will happen } void loop() { int IRval= analogRead(IRreceiver); // declare data Serial.println(IRval); // print the data delay(10); } // add a delay to smoothen things out , After it's uploaded bring up the serial communication., The data should vary as the distance between the sensor and the object varies.

About the Author

J

Joan Peterson

Specializes in breaking down complex organization topics into simple steps.

41 articles
View all articles

Rate This Guide

--
Loading...
5
0
4
0
3
0
2
0
1
0

How helpful was this guide? Click to rate: