1
00:00:06,000 --> 00:00:07,000
Hello, friends.

2
00:00:07,000 --> 00:00:12,000
Today I will tell you how to interface IR sensor.

3
00:00:13,000 --> 00:00:17,000
Or you can say infrared sensor with Arduino.

4
00:00:19,000 --> 00:00:22,000
Using Python programming for that purpose.

5
00:00:23,000 --> 00:00:30,000
I over here, this is my infrared sensor that is connected to the this.

6
00:00:30,000 --> 00:00:32,000
It will this is a module.

7
00:00:33,000 --> 00:00:38,000
In this case, I just use its digital output pin.

8
00:00:38,000 --> 00:00:45,000
I just connect it to the PIN number seven of my Arduino and I just connect positive pin.

9
00:00:46,000 --> 00:00:51,000
Or you can say VCC of my IR sensor to the five volt and ground to the ground.

10
00:00:52,000 --> 00:00:56,000
So now just move to the software part over here.

11
00:00:56,000 --> 00:01:01,000
Just import Arduino library

12
00:01:03,000 --> 00:01:04,000
then.

13
00:01:06,000 --> 00:01:07,000
Import.

14
00:01:12,000 --> 00:01:13,000
Then import time.

15
00:01:19,000 --> 00:01:26,000
After this set up the board just take a variable called.

16
00:01:30,000 --> 00:01:31,000
I already know.

17
00:01:33,000 --> 00:01:37,000
Just set up the baud rate for Arduino.

18
00:01:37,000 --> 00:01:39,000
It is 9600.

19
00:01:42,000 --> 00:01:47,000
Then hold equal to eight.

20
00:01:54,000 --> 00:01:54,000
Call.

21
00:01:55,000 --> 00:02:03,000
Now, in this case, I'm just using digital pin to acquire the signal because I are sensor.

22
00:02:04,000 --> 00:02:07,000
We can use IR sensor for object detection.

23
00:02:07,000 --> 00:02:13,000
So when object is present in front of your IR sensor, it will generate a signal.

24
00:02:13,000 --> 00:02:16,000
Otherwise it will go to sleep.

25
00:02:16,000 --> 00:02:22,000
So you can use Arduino digital pin or analog pin.

26
00:02:22,000 --> 00:02:26,000
Okay, so right now I'm just using digital pin.

27
00:02:26,000 --> 00:02:28,000
I will tell you both ways.

28
00:02:28,000 --> 00:02:35,000
So here just board dot pin mode.

29
00:02:38,000 --> 00:02:44,000
And as you say, one thing and it is an input pin.

30
00:02:48,000 --> 00:02:48,000
Right now.

31
00:02:49,000 --> 00:02:54,000
So now I just use while loop while true.

32
00:02:58,000 --> 00:02:59,000
Inside this.

33
00:02:59,000 --> 00:03:11,000
I just use a variable I sensor that is equal to your board to read.

34
00:03:14,000 --> 00:03:16,000
Crystal Reed.

35
00:03:17,000 --> 00:03:19,000
And the pin number is seven.

36
00:03:20,000 --> 00:03:24,000
Now you just print this value.

37
00:03:26,000 --> 00:03:29,000
Print this value.

38
00:03:30,000 --> 00:03:35,000
Now, I just put some time delay.

39
00:03:38,000 --> 00:03:43,000
So my time delay, let's say it is 0.2 seconds.

40
00:03:46,000 --> 00:03:47,000
Save it.

41
00:03:48,000 --> 00:03:48,000
Run it.

42
00:03:49,000 --> 00:03:51,000
You can check the results.

43
00:03:53,000 --> 00:03:58,000
Of sensor output, it is placing 000.

44
00:03:58,000 --> 00:04:03,000
And when I just place my hand in front of your sensor.

45
00:04:03,000 --> 00:04:06,000
It is sending one signal.

46
00:04:06,000 --> 00:04:11,000
As you see on the i r module also glow.

47
00:04:11,000 --> 00:04:16,000
So this is how you can use your sensor.

48
00:04:17,000 --> 00:04:23,000
With the help of python programming or how you acquire signal.

49
00:04:24,000 --> 00:04:24,000
Oh.

50
00:04:25,000 --> 00:04:26,000
Yes, sir.

51
00:04:26,000 --> 00:04:29,000
This is the digital way.

52
00:04:29,000 --> 00:04:33,000
Now I just go to the analog way.

53
00:04:33,000 --> 00:04:46,000
So for analog way, I just use this pin for I just change this pin from digital pin seven to a zero.

54
00:04:46,000 --> 00:04:49,000
Or you can say right now I'm just using a one.

55
00:04:49,000 --> 00:04:51,000
So now check.

56
00:04:52,000 --> 00:04:54,000
Let's check what happened.

57
00:04:54,000 --> 00:04:58,000
So I just stop it.

58
00:04:59,000 --> 00:05:08,000
So for analog read, I'm just using I'm just importing Arduino time.

59
00:05:09,000 --> 00:05:17,000
Then you just change this because I'm just using analog pin.

60
00:05:18,000 --> 00:05:22,000
So R is equal to board over here.

61
00:05:23,000 --> 00:05:27,000
Analog read in case of.

62
00:05:27,000 --> 00:05:31,000
In case of digital, I just use analog read.

63
00:05:31,000 --> 00:05:33,000
Just put the pin number.

64
00:05:33,000 --> 00:05:38,000
The pin is 1A1 I'm using.

65
00:05:38,000 --> 00:05:44,000
In the case of i r sensor, it will generate around 3.67V.

66
00:05:44,000 --> 00:05:52,000
When signal is there, when object is not there, in that case it will generate zero.

67
00:05:52,000 --> 00:05:56,000
So I'm just again changing this voltage.

68
00:05:57,000 --> 00:06:09,000
So I over here I'm just using the symbol i r r and that i r r is equal to i r into.

69
00:06:11,000 --> 00:06:14,000
Five divided by 1024.

70
00:06:14,000 --> 00:06:16,000
Let's check what happened.

71
00:06:16,000 --> 00:06:24,000
So over here, I'm just using this variable control s save it and run it.

72
00:06:25,000 --> 00:06:28,000
Let's check what happened to it.

73
00:06:29,000 --> 00:06:39,000
It is placing zero zero and now it is generating 3.64003.64.

74
00:06:39,000 --> 00:06:48,000
So this is how you can use air sensor with the help of analog pen also.

75
00:06:48,000 --> 00:06:50,000
In this case, I'm just.

76
00:06:52,000 --> 00:06:54,000
Telling you about.

77
00:06:54,000 --> 00:06:58,000
I told you about how to acquire using digital twin.

78
00:06:58,000 --> 00:07:00,000
How to acquire using analog twin.

79
00:07:00,000 --> 00:07:03,000
Now I'm just change this formula.

80
00:07:04,000 --> 00:07:09,000
If I'm just not, place it over here.

81
00:07:09,000 --> 00:07:10,000
Let's check what happened to it.

82
00:07:11,000 --> 00:07:16,000
So I will directly again run it.

83
00:07:18,000 --> 00:07:19,000
Let's check what happened.

84
00:07:21,000 --> 00:07:22,000
It will generate 000.

85
00:07:22,000 --> 00:07:31,000
And when I place my hand over here, it will generate seven, four, five, 745, because the maximum

86
00:07:31,000 --> 00:07:38,000
range is if five volt is there, it will generate 1024 and right now it is 3.66V.

87
00:07:38,000 --> 00:07:42,000
So now it is generating 7.45.

88
00:07:42,000 --> 00:07:48,000
So this is how you can acquire signal from Iot sensor.

89
00:07:48,000 --> 00:07:49,000
Thank you.

