How to Make a Simple Proximity Sensor Using Arduino
Steps
- 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 connection as follows.
- 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.
- Build your code. 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
- int IRreceiver = A0; // initialize
- Make sure all the connections are safe and then upload the code to your Arduino. After it's uploaded bring up the serial communication.
- Examine the data. The data should vary as the distance between the sensor and the object varies.
- Finished.
4 ★ | 2 Vote
You should read it
- How to program Arduino with an Android phone
- What is Arduino and its applications in life
- Synthesis of useful commands to code the Arduino
- How to install Arduino IDE on Mac
- Download and install Arduino on the computer
- Why is the new Arduino Uno R4 a game changer for manufacturers?
- How to Run a Toy DC Motor by Using Arduino
- How to install the Arduino IDE on CentOS 8
May be interested
- How to install Arduino IDE on Debian 10arduino ide (integrated development environment) is open source software used to interact with arduino control boards. using it, you can connect and communicate with the arduino hardware.
- How to install the Arduino IDE on CentOS 8before starting to create projects via arduino, users need to set up the ide for the programmable board. in this article, tipsmake will join you to learn how to install the latest arduino ide on centos 8.
- How to add libraries in Arduinoardunio libraries are frequently used programs available to help you learn about the limited number of ide sketches.
- How to program Arduino with an Android phoneas an open source electronic platform, arduino boards are very popular for iot projects. although the standard way to use them is to connect the arduino usb ports to the computer, but you can also do so using bluetooth controller and android application.
- How to connect two Arduino boards using I2Cwhile a single arduino can accomplish many tasks, some projects may require the use of more than one board to handle different functions.
- Difference between Elegoo and Arduinoif you've ever bought an arduino board, you may have seen elegoo boards with a cheaper starter kit. both are good options. so what is the difference between elegoo and arduino?
- How to Program Arduino with Raspberry Pirunning a program on an arduino is easy, but have you tried doing it with the pi? the raspberry pi is powerful enough to be a standalone computer and also good enough to program microcontrollers.
- Compare Raspberry Pi and Arduinoboth raspberry pi and arduino are popular boards for iot projects. although they are not the only options, each of these tools has a large following and tons of online resources.
- How to Set Up an Arduino Unoso, you've just bought, or are considering buying, an arduino uno kit. your mind is probably full of questions about how you can get started right away maximizing your experience. nothing is stopping you from coding the next big thing on...
- What is PWM in Arduino?pwm is a widely used concept in physics, electronics and telecommunications. it is defined as a signal modulation form to obtain analog waveforms from digital inputs.