1
00:00:00,930 --> 00:00:04,540
Went on to become this new lesson in what you're going to call the sit up function.

2
00:00:05,230 --> 00:00:11,800
Now first, make sure that the board is selected the way it is be set to get better in one by going

3
00:00:11,800 --> 00:00:18,550
to the SB 32 Arduino and selecting the Do It SPF 30 tool kit.

4
00:00:18,550 --> 00:00:26,840
The gentleman next step you need to ensure that you'll verify the first part of the code that we just

5
00:00:26,840 --> 00:00:30,280
roll to make sure that you have all the right and installed correctly.

6
00:00:32,880 --> 00:00:39,690
Now, once you see they're done compiling, it means that the code is written correctly and we can move

7
00:00:39,690 --> 00:00:41,180
on, as you can see today.

8
00:00:41,220 --> 00:00:47,010
Ambassador function the first thing is enabling the serial monitor.

9
00:00:49,500 --> 00:00:53,510
The highest body, like a hundred fifteen thousand four hundred.

10
00:00:54,970 --> 00:01:04,810
Now we need to make sure that the pin that the motion detectors connected to is configured as in football.

11
00:01:05,840 --> 00:01:12,920
Because we need to receive the value from this bin and we need to enable the pull to stored internally

12
00:01:13,310 --> 00:01:14,180
for that bin.

13
00:01:14,420 --> 00:01:15,170
So pinhole.

14
00:01:19,500 --> 00:01:20,880
Here you need to.

15
00:01:21,870 --> 00:01:23,490
Right now, I'm.

16
00:01:25,600 --> 00:01:28,240
Now, the pin number here is.

17
00:01:29,680 --> 00:01:32,320
Twenty one, so will use censorious to the fighting.

18
00:01:32,600 --> 00:01:33,010
No.

19
00:01:33,980 --> 00:01:35,690
And here, when you try to import.

20
00:01:38,580 --> 00:01:39,060
All of.

21
00:01:40,700 --> 00:01:41,180
That's it.

22
00:01:42,280 --> 00:01:46,120
Now the next step is enabling the interact.

23
00:01:46,730 --> 00:01:53,990
Now we need to receive the sense of signal as interrupt signal that will interrupt any thing that's

24
00:01:53,990 --> 00:02:02,330
happening inside our code and send the message to our Telegram port in order to do this and argue.

25
00:02:02,630 --> 00:02:04,250
It's a very simple thing to do.

26
00:02:04,280 --> 00:02:06,560
So just like Dash?

27
00:02:07,620 --> 00:02:08,250
Interact.

28
00:02:09,720 --> 00:02:15,300
As you can see now, if you have an alternate means that works and you have written it correctly.

29
00:02:16,020 --> 00:02:20,870
Now we need to buy that digital pen to enable the interruption.

30
00:02:20,970 --> 00:02:22,140
So I didn't dump.

31
00:02:23,510 --> 00:02:24,800
Ben, do.

32
00:02:26,070 --> 00:02:30,780
Dropped and the motion sensor pin.

33
00:02:33,130 --> 00:02:36,070
The second value that we need right here.

34
00:02:37,710 --> 00:02:39,180
Is the interrupt functioning?

35
00:02:39,420 --> 00:02:43,080
So you need to buy, let's see, movement.

36
00:02:44,790 --> 00:02:45,420
Depiction.

37
00:02:46,540 --> 00:02:50,290
And you need to create a function with this name, and we will create it in a minute.

38
00:02:51,160 --> 00:02:57,750
The third thing that you need to write is the rising or falling age, whether you want the internet

39
00:02:57,760 --> 00:03:00,490
to happen on the rising or on the following.

40
00:03:01,000 --> 00:03:04,330
Now the easiest way to understand rising and falling edges.

41
00:03:06,510 --> 00:03:09,870
Is by looking to the following schematic.

42
00:03:10,230 --> 00:03:11,700
Now let's say that this is about us.

43
00:03:11,910 --> 00:03:15,630
This is off on, then off again.

44
00:03:17,160 --> 00:03:18,360
Now we call this.

45
00:03:19,550 --> 00:03:23,270
Moving from zero to one facing edge.

46
00:03:23,780 --> 00:03:29,120
So this is the leading edge of eyeballs now moving from one to zero.

47
00:03:29,420 --> 00:03:34,880
We call it the falling edge because as you can see, the bus is falling down from one to zero.

48
00:03:36,020 --> 00:03:39,320
So this one is called rising.

49
00:03:42,100 --> 00:03:43,900
This one is called falling.

50
00:03:46,370 --> 00:03:51,680
Well, sometimes it matters, you can do something when you are underwriting a judgment and another

51
00:03:51,680 --> 00:03:56,210
thing when you are and the following it's not in our case, it doesn't matter.

52
00:03:56,240 --> 00:03:59,000
So we were right, rising or falling.

53
00:03:59,540 --> 00:04:03,620
Well, now we will go with rising interest would be enabled on this ben.

54
00:04:05,040 --> 00:04:09,600
And once the anthrax happens on the rising edge, it will call this function.

55
00:04:09,870 --> 00:04:12,060
Now we haven't yet written dysfunction.

56
00:04:12,570 --> 00:04:13,800
So we need to write it now.

57
00:04:14,980 --> 00:04:16,360
Now, Kobe, the function name.

58
00:04:17,820 --> 00:04:20,250
Go up here before the vote set up.

59
00:04:21,490 --> 00:04:23,740
On this grave dysfunction, I void.

60
00:04:27,120 --> 00:04:28,260
And right.

61
00:04:29,660 --> 00:04:30,650
The function name.

62
00:04:32,960 --> 00:04:39,360
And inside it, we need to find a function called the code would include only one line if motion is

63
00:04:39,360 --> 00:04:39,920
detected.

64
00:04:41,580 --> 00:04:46,750
This function will be called, so we need to sit down and detected two faults.

65
00:04:47,240 --> 00:04:48,030
It's not a control.

66
00:04:50,670 --> 00:04:51,960
Now you need to right here.

67
00:04:53,520 --> 00:04:55,080
I farm.

68
00:04:56,110 --> 00:05:02,740
And those four attributes, this is something you have tried before in the function name in order to

69
00:05:02,740 --> 00:05:03,670
enable this function.

70
00:05:04,510 --> 00:05:10,180
Now, when motion is detected, we needed to write and detected through now in order to make sure that

71
00:05:10,180 --> 00:05:11,300
everything works fine.

72
00:05:11,320 --> 00:05:20,430
We can't send on the front line to prevent that motion is detected motion as being the.

73
00:05:24,100 --> 00:05:28,900
OK, so we'll send this for debugging, and we will sit time detective to explore.

74
00:05:29,920 --> 00:05:35,540
So again, when the first thing that we did here is enabling the 7th of October debugging.

75
00:05:35,860 --> 00:05:42,310
The second thing is setting the absence of a pin for the motion detectors and sort of as input.

76
00:05:42,730 --> 00:05:46,540
Then we enable the interrupt on this pin.

77
00:05:48,440 --> 00:05:53,930
And one tenth of what happens on the rising edge, as we already explained, it will call the movement

78
00:05:54,470 --> 00:05:59,960
detection function the moment the action function will execute these two lines of code.

79
00:06:00,260 --> 00:06:05,450
It was said that detected valuable to through and it will print this on the serial monitor.

80
00:06:06,760 --> 00:06:07,240
Now.

81
00:06:08,330 --> 00:06:11,120
We are done with the motion detection force.

82
00:06:11,870 --> 00:06:17,230
Let's do the wi fi part, so let's both see real offense.

83
00:06:21,950 --> 00:06:22,820
Why fi?

84
00:06:25,000 --> 00:06:29,020
Or trying to connect the Wi-Fi.

85
00:06:31,570 --> 00:06:37,150
Now we need to ride the Wi-Fi network CCTV off of this line.

86
00:06:38,730 --> 00:06:42,200
So Syria with friend and.

87
00:06:44,840 --> 00:06:48,220
This idea that a society is the variable that we created here.

88
00:06:49,730 --> 00:06:50,420
In this line.

89
00:06:51,540 --> 00:06:57,390
And whatever we like here, it will be written when we call the brand new line function.

90
00:06:57,810 --> 00:07:04,560
Now we added print and print new line here because we want to print this sentence on one line and proceed

91
00:07:04,560 --> 00:07:06,660
with printing this on the same line.

92
00:07:07,080 --> 00:07:11,430
After that, we want to go to a new line and that's why we added and here.

93
00:07:12,630 --> 00:07:18,360
So print will print on the same line print and we'll print on the same line, but it will add a new

94
00:07:18,360 --> 00:07:20,070
line after finished printing.

95
00:07:21,550 --> 00:07:25,600
Now, to connect to our iPhone, we need to arrive the following sentences.

96
00:07:25,690 --> 00:07:30,970
Now you can't see this, though the iPhone library not ready for you to yours.

97
00:07:31,120 --> 00:07:32,260
So right, Wi-Fi?

98
00:07:33,390 --> 00:07:40,770
Steve, this is a microphone for the Wi-Fi function now like the iPhone that began.

99
00:07:42,170 --> 00:07:44,210
It will take two variables a society.

100
00:07:46,070 --> 00:07:46,700
The passport.

101
00:07:49,450 --> 00:07:54,220
Once you have done with this, the only thing that we need to do now is.

102
00:07:55,590 --> 00:08:05,220
Add something called road certification for API Telegram bots, so to do that, you need to write the

103
00:08:05,220 --> 00:08:07,440
following when you need to call the client.

104
00:08:09,180 --> 00:08:11,100
And I'd sit.

105
00:08:12,560 --> 00:08:13,760
A certificate.

106
00:08:15,700 --> 00:08:20,980
This is a function inside the client and pass the telegram.

107
00:08:22,910 --> 00:08:23,990
Certificate.

108
00:08:25,580 --> 00:08:26,090
Tea.

109
00:08:27,110 --> 00:08:29,240
It gets underscored.

110
00:08:30,740 --> 00:08:31,580
Do that function.

111
00:08:31,700 --> 00:08:35,780
So SIT Certificate will call telegrams and certificates.

112
00:08:36,860 --> 00:08:42,549
Now the next step is to make sure that we are actually connected to Wi-Fi and this is done using our

113
00:08:42,590 --> 00:08:43,190
statements.

114
00:08:45,890 --> 00:08:48,470
This little statement will take.

115
00:08:50,020 --> 00:08:50,920
The Wi-Fi.

116
00:08:52,180 --> 00:08:53,050
The status.

117
00:08:54,980 --> 00:09:01,370
Function that returns the Wi-Fi connection status if it does not equal wireless connected.

118
00:09:03,520 --> 00:09:05,440
It will print dots.

119
00:09:07,020 --> 00:09:07,770
So Syrian.

120
00:09:08,810 --> 00:09:09,620
So, friends.

121
00:09:12,850 --> 00:09:18,550
Dots will keep planting dots until we are connected to the Wi-Fi network, and we will either delay.

122
00:09:19,880 --> 00:09:24,200
Of 500 or the sea, 300 milliseconds.

123
00:09:26,480 --> 00:09:30,110
Now, once we are done, we are connected and we put out Syrian.

124
00:09:31,350 --> 00:09:32,820
The brand new line.

125
00:09:34,540 --> 00:09:40,180
And a new line then of the sentence by five convicted.

126
00:09:45,400 --> 00:09:46,180
Why fine?

127
00:09:48,440 --> 00:09:49,130
And, Nic, good.

128
00:09:51,050 --> 00:09:53,330
Then the IP address.

129
00:09:55,560 --> 00:09:57,210
Make sure that you are actually connected.

130
00:09:58,560 --> 00:09:59,520
I address.

131
00:10:03,230 --> 00:10:05,150
And the last step is.

132
00:10:06,870 --> 00:10:11,220
Writing the IP address itself by find.

133
00:10:13,450 --> 00:10:14,470
The local.

134
00:10:17,970 --> 00:10:18,510
IP.

135
00:10:19,930 --> 00:10:25,630
This function will tell the IP address for our Wi-Fi, although our ISP 32.

136
00:10:27,050 --> 00:10:27,560
That's it.

137
00:10:28,070 --> 00:10:30,410
Now the last step is sending a message.

138
00:10:30,680 --> 00:10:31,340
So about.

139
00:10:32,260 --> 00:10:32,710
Dot.

140
00:10:34,530 --> 00:10:41,910
Send message, this message will include the following that chart idea, which is basically the variable

141
00:10:41,910 --> 00:10:43,980
that we gathered here, our chart idea.

142
00:10:46,470 --> 00:10:47,070
And.

143
00:10:49,010 --> 00:10:50,990
It will send books.

144
00:10:53,210 --> 00:10:55,290
Stops of.

145
00:10:59,420 --> 00:10:59,930
Motion.

146
00:11:02,630 --> 00:11:06,260
Motion Picture Motion Picture.

147
00:11:08,320 --> 00:11:16,450
What started up and we will send them this thing, which is the third end, but now we need to make

148
00:11:16,450 --> 00:11:23,380
sure to pass our chat I.D. to make sure that our ISP will only receive messages from us, not from anyone

149
00:11:23,380 --> 00:11:23,740
else.

150
00:11:24,910 --> 00:11:31,120
Once we have done with that, only one step remains, which is programming that all statements.

151
00:11:32,620 --> 00:11:38,140
Now, before moving forward, let's explain what we have done so far and in the next lesson from program

152
00:11:38,140 --> 00:11:38,920
that statement.

153
00:11:39,850 --> 00:11:46,510
Now first, we enable the serial monitor you are signed up in and pull up.

154
00:11:47,500 --> 00:11:52,720
To enable double our brothers sisters, and I'm sensitive to the pin number for the motion detector,

155
00:11:53,530 --> 00:11:55,980
we enable interrupt on this pin.

156
00:11:56,740 --> 00:12:03,370
And once that interrupt takes place, once we receive a signal on the rising edge from the motion picture,

157
00:12:03,790 --> 00:12:06,640
we will call the interrupt function, or ESR.

158
00:12:07,720 --> 00:12:08,920
This interrupt function.

159
00:12:10,560 --> 00:12:16,380
Well, planned on the settlement, a motion has been detected and it will die.

160
00:12:17,800 --> 00:12:23,650
Now undetected, well, equal rule, and we already mentioned that this is the variable that we are

161
00:12:24,040 --> 00:12:27,490
using to enable or disable also.

162
00:12:28,440 --> 00:12:36,360
The detection now we go back here and planned on the sheer amount of trying to connect to, I find we

163
00:12:36,360 --> 00:12:41,920
print this idea for our Wi-Fi network and we said the final toast to.

164
00:12:42,720 --> 00:12:46,830
Then we begin the life.I connection using devices I.D. and the password.

165
00:12:47,550 --> 00:12:54,330
Once done, we send the Telegram birth certificate using client that said certificate and by writing

166
00:12:54,330 --> 00:12:55,050
this macro.

167
00:12:56,150 --> 00:13:00,740
We don't know or we don't have to know what's written inside this.

168
00:13:01,820 --> 00:13:05,690
It's already written in the Telegram bot library.

169
00:13:06,230 --> 00:13:09,590
Now next, we need to make sure that we are actually connected to qualify.

170
00:13:10,010 --> 00:13:11,720
So we'll check wi fi status.

171
00:13:12,410 --> 00:13:14,630
If it is not connected, we will keep printing dots.

172
00:13:16,520 --> 00:13:19,850
If it is connected, then we will get out of this wide loop.

173
00:13:22,480 --> 00:13:27,620
Once done, we will go here and we will plant a new into line.

174
00:13:27,640 --> 00:13:30,220
We will identify connected and we will.

175
00:13:30,760 --> 00:13:33,430
And let's separate the IP address.

176
00:13:34,450 --> 00:13:42,910
As you can see, why find local IP on the last tip is sending a welcome message to indicate to our Telegram

177
00:13:42,910 --> 00:13:50,170
chat bot that the device or our ISP towards ON so it will try Motrin and Temperatura both started up

178
00:13:50,500 --> 00:13:52,780
using the send message feature.

179
00:13:54,880 --> 00:13:59,980
Now, in the next step, we will program that all function and start the testing process.

180
00:14:00,610 --> 00:14:01,960
Thanks for sharing this lesson.

181
00:14:02,290 --> 00:14:04,930
This is Ashraf from educational engineering team.

