VERY EASY Arduino IR Sensor Tutorial for Beginners | IR Sensor Arduino Tutorial | Infrared Sensor
Summary
TLDRThis tutorial demonstrates how to use an IR proximity sensor with an Arduino to operate various devices. It covers the sensor's working principle, circuit diagrams, and source code. The sensor detects objects within 2 to 60 cm and its sensitivity is adjustable. The video guides through connecting the sensor to Arduino, calibrating it, and uploading sample code that triggers a buzzer and displays sensor status on the serial monitor. It also suggests modifying the code for different applications and using a relay module for motors or appliances.
Takeaways
- 🔍 The video demonstrates how to use an IR proximity sensor with an Arduino board to operate various devices.
- 💡 The sensor consists of an infrared emitter and a receiver, which can detect objects within a range of 2 to 60 centimeters.
- 🔧 The sensitivity of the sensor can be adjusted using a potentiometer.
- 🔌 The sensor is connected to the Arduino using three jumper wires, linking VCC, ground, and the output pin to the board's corresponding pins.
- 📢 A 5-volt active buzzer is used as an indicator, connected to digital pin 8 and ground.
- 🖥️ The Arduino board is connected to a computer via USB for programming and power.
- 🔧 The sensor's calibration involves placing an object at a specific distance and adjusting the potentiometer until the obstacle LED turns on and off correctly.
- 📝 The provided Arduino code includes setup and loop functions, with the loop function checking the sensor's state and controlling the buzzer accordingly.
- 👀 The code differentiates between a high signal (no object detected) and a low signal (object detected), triggering the buzzer and serial monitor messages.
- 🛠️ Beginners can refer to a previous tutorial for uploading code to the Arduino board, linked in the video description.
- 🔄 The buzzer and serial monitor demonstrate the sensor's functionality in real-time when an object is near or away.
- 🔌 The tutorial suggests using a relay module to control motors or other appliances with the IR sensor for more complex projects.
Q & A
What is the purpose of the infrared emitter in the proximity sensor?
-The infrared emitter in the proximity sensor emits IR signals which, when they hit an object, bounce back and are detected by the IR receiver, allowing the sensor to detect objects within a certain range.
How can the sensitivity of the proximity sensor be adjusted?
-The sensitivity of the proximity sensor can be adjusted by rotating the potentiometer, which helps in calibrating the sensor to detect objects at the desired distance.
What are the three connections required to connect the proximity sensor to the Arduino board?
-The three connections required are: VCC pin of the sensor to the 5V pin of Arduino, the ground pin of the sensor to the ground pin of Arduino, and the OUT pin of the sensor to digital pin 2 of Arduino.
How is the buzzer connected to the Arduino board in the tutorial?
-The buzzer is connected to the Arduino board using two male-to-female jumper wires, with the positive pin connected to digital pin 8 of Arduino and the negative pin connected to the ground pin of Arduino.
What is the function of the serial communication in the Arduino code provided in the tutorial?
-The serial communication in the Arduino code starts at a baud rate of 9600, which allows the Arduino to communicate with the computer and print messages on the serial monitor.
What does the 'sensor status' variable in the code represent?
-The 'sensor status' variable in the code represents the digital input from the IR sensor, which is used to determine whether an object is detected or not.
How does the code differentiate between the presence and absence of an object in front of the sensor?
-The code checks the digital state of the sensor; it outputs a low signal when an object is detected and a high signal when no object is present. Based on this, the code turns the buzzer on or off and prints the corresponding message on the serial monitor.
What is the purpose of the delay in the loop function of the Arduino code?
-The delay in the loop function of the Arduino code, set to 500 milliseconds, ensures that the code does not loop too quickly, giving the sensor time to stabilize and accurately detect objects.
How can the basic code provided in the tutorial be modified to control other devices like motors?
-The basic code can be modified by using a relay module instead of the buzzer, which allows the IR sensor to control motors or other electrical appliances.
What additional tutorial is recommended for those who want to learn about using relays with Arduino?
-The tutorial creator recommends watching a detailed tutorial about using relays with Arduino, which will provide insights on how to implement such functionality.
Outlines
🛠 Arduino Proximity Sensor Tutorial Overview
This paragraph introduces a tutorial on using a proximity sensor with an Arduino board. It explains the basic components of the sensor, including an infrared emitter and receiver, and how they work together to detect objects within a range of 2 to 60 centimeters. The tutorial covers circuit diagrams, source codes, and a guide on how to subscribe to the channel for more content. The sensitivity of the sensor is adjustable via a potentiometer, and the connection process to the Arduino is detailed, including the use of jumper wires and specific pin connections.
🔍 Calibrating and Testing the Proximity Sensor with Arduino
The second paragraph delves into the calibration process of the proximity sensor, which involves adjusting the potentiometer to set the detection distance and using an obstacle LED for visual feedback. It also covers the uploading of the provided Arduino code, which includes pin declarations, setup functions for serial communication, and the loop function that reads the sensor's state and controls a buzzer accordingly. The code checks for a low signal indicating an object's presence and toggles the buzzer and prints messages on the serial monitor. Additionally, the paragraph suggests modifying the code for controlling other devices like motors through a relay module and refers to a related tutorial for further guidance.
Mindmap
Keywords
💡Proximity Sensor
💡Arduino
💡Infrared Emitter
💡IR Receiver
💡Sensitivity
💡Circuit Diagrams
💡Source Codes
💡Buzzer
💡Calibration
💡Serial Monitor
💡Relay Module
Highlights
Tutorial on using a proximity sensor with Arduino to operate various devices.
Introduction to the infrared emitter and receiver of the proximity sensor.
Explanation of the sensor's detection range from 2 to 60 centimeters.
Demonstration of adjusting sensor sensitivity with a potentiometer.
Connection of the proximity sensor to the Arduino board using jumper wires.
Setup of a 5-volt active buzzer and its connection to the Arduino.
Arduino board connection to a computer for programming.
Calibration process of the sensor using an object and the potentiometer.
Download and opening of the provided Arduino IR obstacle sensor code.
Code explanation including pin declarations and setup function.
Description of the loop function and its role in sensor operation.
Condition checking for sensor status and corresponding actions.
Serial monitor output demonstrating sensor state.
Guidance for beginners on uploading code to the Arduino board.
Observation of buzzer activation and deactivation with sensor interaction.
Suggestion to modify the basic code for different applications.
Mention of using a relay module for controlling motors or appliances.
Invitation to subscribe for future tutorial videos.
Transcripts
foreign
proximity sensor with Arduino
I will show you how the sensor is
working and how to operate various
devices with it
this tutorial will include the circuit
diagrams and required Source codes for
the project
so before going to the tutorial I invite
you to subscribe my channel and click
the Bell icon to get the future videos
like this
now let's take a look into the sensor
this clear LED is an infrared emitter
which emits IR signals
when it hits an object it will bounce
back and detects by this black color IR
receiver
it can detect objects within 2 to 60
centimeters
we can adjust the sensitivity of this
sensor by rotating this potentiometer
let's connect this sensor with the
Arduino board
take three male to female jumper wires
and connect them with the sensor
first connect the VCC pin of sensor with
the 5 volt pin of Arduino
[Music]
next connect the ground pin of the
sensor with the ground pin of the
Arduino
[Music]
finally connect the out pin with digital
pin 2 of Arduino
then take a 5 volt active buzzer and
connect two male to female jumper wires
with the
connect positive pin with digital pin 8
of Arduino
connect the negative pin of the basa
with the ground pin of the Arduino
next plug the Arduino board to the
computer using an USB cable
you will see this power LED is
indicating
the other LED is obstacle detection LED
we can use it to adjust the sensitivity
of the module
to do this calibration put an object in
front of the sensor in required distance
I will put this object in few
centimeters away from the sensor
then I will turn this potentiometer into
the exact place where the object LED
starts to on
then remove the object and observe the
obstacle LED
it should turn off
then place the object again in the same
location
then it should turn on again
now we have calibrated the sensor to use
simna project
now download and open this code named
Arduino IR obstacle sensor
[Music]
in first two lines it has declared the
pins which IR sensor and basa have
connected
now let's come into the setup function
from this line it has to start at the
serial communication at the speed of
9600 about rate
from this line it has declared the IR
sensor as a input device for the Arduino
from next line it has declared the
buzzer as a output device for Arduino
now let's come to the loop function
which runs again and again
from this line it treats the digital
input from the IR sensor and saves it in
a variable called sensor status
from this shift condition it checks the
sensor's digital state
these types of ir sensors will output a
low signal when an object is detected
when there is no any object it will
output a high signal
[Music]
so if the sensor outputs a low signal it
will check that from this if condition
and execute these two lines
[Music]
from this line it will turn on the
buzzer
this line will print and object is
detected message on the serial monitor
if sensor status is 1 it will execute
this else part
this will turn off the buzzer while
printing no objects for detected message
on serial monitor
this line will put a delay of 500
milliseconds before going to the next
cycle
now let's upload the code into the
Arduino bow
if you are a beginner for Arduino
programming and don't know how to upload
codes for the Arduino board please watch
my previous tutorial called Arduino
tutorial for beginners
I will put its Link in the video
description
ok now keep an object in front of the
sensor and observe
[Music]
yes you can see that it will turn on the
buzzer when we keep the object near
sensor
and it will turn off when we take it
away
at the same time open the serial Monitor
and observe the text on it
it also shows the relevant state of the
sensor
we can modify this basic code to do
various things
if you want to run Motors or any other
electrical appliances from this IR
sensor you can use a relay module
instead of this buzzer
I have created a very detailed tutorial
about the way of using a relays with
arduino's
please watch it and get an idea about it
I will put its Link in the video
description
this is the way of using an IR proximity
sensor with Arduino
[Music]
don't forget to subscribe my channel to
see my future videos like this
[Music]
浏览更多相关视频
How to Use a TCS3200 Color Sensor with Arduino (Lesson #38)
IR sensor working || all about arduino IR sensor
INTEGRATION OF SENSOR AND ACTUATORS WITH ARDUINO-I
pH meter Arduino, pH Meter Calibration, DIYMORE pH Sensor, pH Sensor Arduino Code, pH of liquids
Getting Started with Microsoft Azure IoT Central using NodeMCU ESP8266
How to use sensors with Arduino
5.0 / 5 (0 votes)