VERY EASY Arduino IR Sensor Tutorial for Beginners | IR Sensor Arduino Tutorial | Infrared Sensor

Tronics lk
23 Sept 202207:21

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

00:00

πŸ›  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.

05:02

πŸ” 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

A proximity sensor is a device that detects the presence of nearby objects without physical contact. In the context of the video, it is an infrared (IR) sensor that emits IR signals and detects them when they bounce back after hitting an object. The sensor's theme revolves around its ability to operate devices based on the detection of objects within a specific range, as demonstrated with the Arduino board.

πŸ’‘Arduino

Arduino is an open-source electronics platform based on easy-to-use hardware and software. It is used for building various projects that interact with the environment. In the video, the Arduino board is central to connecting and programming the proximity sensor to perform tasks such as triggering a buzzer when an object is detected.

πŸ’‘Infrared Emitter

An infrared emitter is a component that emits infrared light, which is invisible to the naked eye. In the video, the clear LED acts as an infrared emitter, sending out IR signals that are essential for the proximity sensor to function by detecting objects within a certain distance.

πŸ’‘IR Receiver

The IR receiver is the component that detects the infrared signals reflected back from an object. In the script, the black-colored IR receiver is responsible for receiving the bounced-back IR signals, which allows the sensor to determine if an object is within its detection range.

πŸ’‘Sensitivity

Sensitivity in the context of the video refers to the ability of the proximity sensor to detect objects at varying distances or under different conditions. The script mentions adjusting the sensor's sensitivity by rotating a potentiometer, which is crucial for calibrating the sensor to work effectively within the desired range.

πŸ’‘Circuit Diagrams

Circuit diagrams are visual representations of an electrical circuit, showing the components and their connections. The video promises to include circuit diagrams as part of the tutorial, which would guide viewers on how to correctly connect the proximity sensor to the Arduino board for the project.

πŸ’‘Source Codes

Source codes are the lines of instructions written in a programming language that control the operation of a device or system. The video mentions required source codes for the project, indicating that viewers will need to use and possibly modify the provided code to make the proximity sensor work with the Arduino.

πŸ’‘Buzzer

A buzzer is an audible signal device that makes a noise when activated. In the video, a 5-volt active buzzer is connected to the Arduino and is used as an output device to provide an audible alert when the proximity sensor detects an object, demonstrating the sensor's functionality.

πŸ’‘Calibration

Calibration is the process of adjusting a device or system to ensure it provides accurate and reliable results. The script describes a calibration process for the proximity sensor where an object is placed at a certain distance, and the potentiometer is adjusted until the sensor's LED turns on, indicating accurate detection.

πŸ’‘Serial Monitor

The serial monitor is a feature in the Arduino software that allows users to view and send data to and from the Arduino board. The video script mentions using the serial monitor to observe messages indicating whether an object has been detected by the sensor, providing a visual confirmation of the sensor's operation.

πŸ’‘Relay Module

A relay module is an electronic device that allows a low-power control signal to switch a high-power device on or off. The script suggests using a relay module instead of a buzzer to extend the project's capabilities, such as controlling motors or other electrical appliances with the proximity sensor.

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

play00:00

foreign

play00:06

proximity sensor with Arduino

play00:10

I will show you how the sensor is

play00:12

working and how to operate various

play00:14

devices with it

play00:17

this tutorial will include the circuit

play00:19

diagrams and required Source codes for

play00:22

the project

play00:23

so before going to the tutorial I invite

play00:26

you to subscribe my channel and click

play00:28

the Bell icon to get the future videos

play00:30

like this

play00:33

now let's take a look into the sensor

play00:38

this clear LED is an infrared emitter

play00:41

which emits IR signals

play00:44

when it hits an object it will bounce

play00:47

back and detects by this black color IR

play00:49

receiver

play00:52

it can detect objects within 2 to 60

play00:55

centimeters

play00:57

we can adjust the sensitivity of this

play00:59

sensor by rotating this potentiometer

play01:02

let's connect this sensor with the

play01:04

Arduino board

play01:07

take three male to female jumper wires

play01:09

and connect them with the sensor

play01:19

first connect the VCC pin of sensor with

play01:23

the 5 volt pin of Arduino

play01:25

[Music]

play01:28

next connect the ground pin of the

play01:31

sensor with the ground pin of the

play01:33

Arduino

play01:34

[Music]

play01:35

finally connect the out pin with digital

play01:39

pin 2 of Arduino

play01:43

then take a 5 volt active buzzer and

play01:45

connect two male to female jumper wires

play01:47

with the

play01:56

connect positive pin with digital pin 8

play01:59

of Arduino

play02:04

connect the negative pin of the basa

play02:06

with the ground pin of the Arduino

play02:13

next plug the Arduino board to the

play02:16

computer using an USB cable

play02:20

you will see this power LED is

play02:22

indicating

play02:24

the other LED is obstacle detection LED

play02:28

we can use it to adjust the sensitivity

play02:31

of the module

play02:37

to do this calibration put an object in

play02:40

front of the sensor in required distance

play02:44

I will put this object in few

play02:46

centimeters away from the sensor

play02:50

then I will turn this potentiometer into

play02:53

the exact place where the object LED

play02:55

starts to on

play03:00

then remove the object and observe the

play03:03

obstacle LED

play03:05

it should turn off

play03:08

then place the object again in the same

play03:10

location

play03:12

then it should turn on again

play03:15

now we have calibrated the sensor to use

play03:18

simna project

play03:24

now download and open this code named

play03:27

Arduino IR obstacle sensor

play03:32

[Music]

play03:40

in first two lines it has declared the

play03:43

pins which IR sensor and basa have

play03:45

connected

play03:48

now let's come into the setup function

play03:53

from this line it has to start at the

play03:56

serial communication at the speed of

play03:58

9600 about rate

play04:03

from this line it has declared the IR

play04:05

sensor as a input device for the Arduino

play04:10

from next line it has declared the

play04:13

buzzer as a output device for Arduino

play04:17

now let's come to the loop function

play04:19

which runs again and again

play04:23

from this line it treats the digital

play04:25

input from the IR sensor and saves it in

play04:28

a variable called sensor status

play04:32

from this shift condition it checks the

play04:35

sensor's digital state

play04:37

these types of ir sensors will output a

play04:41

low signal when an object is detected

play04:44

when there is no any object it will

play04:47

output a high signal

play04:48

[Music]

play04:50

so if the sensor outputs a low signal it

play04:53

will check that from this if condition

play04:54

and execute these two lines

play04:57

[Music]

play05:01

from this line it will turn on the

play05:04

buzzer

play05:06

this line will print and object is

play05:08

detected message on the serial monitor

play05:12

if sensor status is 1 it will execute

play05:15

this else part

play05:18

this will turn off the buzzer while

play05:20

printing no objects for detected message

play05:22

on serial monitor

play05:26

this line will put a delay of 500

play05:28

milliseconds before going to the next

play05:30

cycle

play05:32

now let's upload the code into the

play05:34

Arduino bow

play05:40

if you are a beginner for Arduino

play05:42

programming and don't know how to upload

play05:44

codes for the Arduino board please watch

play05:46

my previous tutorial called Arduino

play05:49

tutorial for beginners

play05:51

I will put its Link in the video

play05:53

description

play05:56

ok now keep an object in front of the

play05:59

sensor and observe

play06:01

[Music]

play06:03

yes you can see that it will turn on the

play06:06

buzzer when we keep the object near

play06:08

sensor

play06:12

and it will turn off when we take it

play06:14

away

play06:16

at the same time open the serial Monitor

play06:19

and observe the text on it

play06:22

it also shows the relevant state of the

play06:26

sensor

play06:28

we can modify this basic code to do

play06:30

various things

play06:33

if you want to run Motors or any other

play06:35

electrical appliances from this IR

play06:37

sensor you can use a relay module

play06:40

instead of this buzzer

play06:43

I have created a very detailed tutorial

play06:46

about the way of using a relays with

play06:48

arduino's

play06:50

please watch it and get an idea about it

play06:54

I will put its Link in the video

play06:56

description

play07:00

this is the way of using an IR proximity

play07:03

sensor with Arduino

play07:06

[Music]

play07:08

don't forget to subscribe my channel to

play07:11

see my future videos like this

play07:15

[Music]

Rate This
β˜…
β˜…
β˜…
β˜…
β˜…

5.0 / 5 (0 votes)

Related Tags
ArduinoIR SensorObstacle DetectionProximity SensorCircuit DiagramSource CodeTutorialDevice ControlSensor CalibrationDIY Project