1
00:00:00,750 --> 00:00:01,650
Hello and welcome.

2
00:00:03,270 --> 00:00:08,820
In this lesson, we are going to take on the P.W. ambitions of the ESB board.

3
00:00:09,900 --> 00:00:18,060
All 36 of the ESB 32 general purpose Input-Output Benz has a P.W. arm capability.

4
00:00:19,190 --> 00:00:20,720
This is a really great thing.

5
00:00:21,840 --> 00:00:27,570
But we must use more complex code to reach the same result on other pins.

6
00:00:29,300 --> 00:00:35,840
So let's put it on one of the general purpose, Input-Output with a P.W. output signal.

7
00:00:36,740 --> 00:00:46,390
Now if you went to this schematic all this pin out for various people, you can see that all of these

8
00:00:46,400 --> 00:00:50,420
pins can be used to generate P.W. arm signals.

9
00:00:51,350 --> 00:00:59,540
The first thing that you need to think about when programming a P.W. on the signal is its frequency.

10
00:01:00,110 --> 00:01:04,400
You need to retrieve that signal at a certain or specific frequency.

11
00:01:04,940 --> 00:01:07,970
We will use a value of 5000 hertz.

12
00:01:08,720 --> 00:01:10,820
That works fine with our lead.

13
00:01:11,480 --> 00:01:18,800
We must also specify that it P.W. and channel and the resolution of the BW and duty cycle.

14
00:01:19,820 --> 00:01:20,500
I want.

15
00:01:21,690 --> 00:01:28,470
Explain that BWR, because you must have some basic knowledge about BW on signals, but what it takes

16
00:01:28,470 --> 00:01:32,970
is also the ocean, a channel and a frequency.

17
00:01:33,750 --> 00:01:42,750
So after specifying that you to cycle using the solution and the frequency on the channel, we can start

18
00:01:42,750 --> 00:01:43,350
programming.

19
00:01:43,950 --> 00:01:50,040
We can choose a channel from zero to 15 and a resolution between one and 16 bits.

20
00:01:50,760 --> 00:01:54,960
We will use Channel zero and a resolution of eight bits.

21
00:01:55,380 --> 00:01:57,660
So let's get started.

22
00:01:57,720 --> 00:02:00,240
That's good, according to your thumbnail sketch.

23
00:02:01,500 --> 00:02:03,240
And here's a new sketch.

24
00:02:03,330 --> 00:02:05,310
Let's define some variables.

25
00:02:05,700 --> 00:02:10,199
First, we need to define that frequency and frequency.

26
00:02:11,009 --> 00:02:12,690
And let's make it 5000.

27
00:02:14,580 --> 00:02:16,110
Then we need the left channel.

28
00:02:18,660 --> 00:02:23,130
Let's make it zero and we need the resolution.

29
00:02:26,070 --> 00:02:29,610
And let's make it eight now.

30
00:02:30,330 --> 00:02:33,180
Let's use that general purpose, Input-Output win.

31
00:02:33,780 --> 00:02:38,800
Number two, where we have our lead on our external LED connected or at best.

32
00:02:39,100 --> 00:02:42,090
It's also has a built in lid that can be used.

33
00:02:42,720 --> 00:02:49,110
So these parameters must be defined inside the setup function.

34
00:02:49,440 --> 00:02:52,620
So let's go on why this gold?

35
00:02:53,610 --> 00:03:01,470
Now what we are going to write in inside the setup function won't be something we are used to, while

36
00:03:01,470 --> 00:03:05,790
going to likely see a dustbin and Lid C sit up.

37
00:03:06,480 --> 00:03:09,570
Now the Let's See attachment and let's use it up.

38
00:03:09,570 --> 00:03:14,100
There are basically functions for the BW arm configuration.

39
00:03:14,550 --> 00:03:18,090
They are very similar to analog write function and Arduino.

40
00:03:18,900 --> 00:03:21,870
So now the DSP.

41
00:03:22,940 --> 00:03:29,260
Doesn't support another great function, but it does support a much better one, which is the one that

42
00:03:29,270 --> 00:03:30,230
we already mentioned.

43
00:03:30,560 --> 00:03:32,720
Let's see right there.

44
00:03:32,720 --> 00:03:33,040
Let's see.

45
00:03:33,040 --> 00:03:35,810
A light function is very similar to another light.

46
00:03:35,840 --> 00:03:45,410
It also requires two parameters that BW channel that we want to write about Utah and the BW value.

47
00:03:45,440 --> 00:03:48,290
We want to write to the selected channel.

48
00:03:49,280 --> 00:03:57,050
Now, let's first finish the setup function now the let's see setup function.

49
00:04:00,520 --> 00:04:01,960
Will take three parameters.

50
00:04:02,150 --> 00:04:03,940
The first one will be the child.

51
00:04:07,160 --> 00:04:10,340
The second one will be the frequency.

52
00:04:10,940 --> 00:04:14,840
The third one will be the resolution, which we already defined up there.

53
00:04:19,790 --> 00:04:26,340
Next, we are going to assign a lead to that channel, so let see at that pin.

54
00:04:28,770 --> 00:04:38,900
Now the lid pin we already chose is two and we want to attach it to that channel that we have chosen.

55
00:04:40,790 --> 00:04:41,380
This is it.

56
00:04:41,390 --> 00:04:49,820
This is how you finish setting up that BW, um, frequency resolution and channel and how you can attach

57
00:04:49,820 --> 00:04:52,010
it to any output pin.

58
00:04:53,970 --> 00:05:02,570
Now to turn the lid, which is connected to PIN number two using the lid channel output from the VW

59
00:05:02,820 --> 00:05:03,360
signal.

60
00:05:04,170 --> 00:05:10,140
We need to set a specific brightness now to turn it on or off.

61
00:05:10,230 --> 00:05:14,430
We must define the duty cycle, for example, turn off the lid.

62
00:05:14,730 --> 00:05:16,320
That cycle must be zero.

63
00:05:16,530 --> 00:05:25,560
And the function lid see right that we already mentioned can be used inside the loop to set the brightness

64
00:05:25,560 --> 00:05:26,040
to zero.

65
00:05:26,500 --> 00:05:26,970
Now.

66
00:05:28,750 --> 00:05:30,950
We can use that function right now.

67
00:05:30,970 --> 00:05:31,390
That's right.

68
00:05:31,420 --> 00:05:31,930
Let's see.

69
00:05:32,140 --> 00:05:32,590
Right.

70
00:05:35,140 --> 00:05:37,270
It's exactly like analog, right?

71
00:05:37,280 --> 00:05:38,920
And it takes two parameters.

72
00:05:38,920 --> 00:05:43,000
The first one is the lead channel, which is this variable.

73
00:05:43,890 --> 00:05:47,770
And the second one is the duty cycle.

74
00:05:49,810 --> 00:05:56,740
Now you can add in duty cycle here and add zero.

75
00:05:56,920 --> 00:06:01,660
This will turn off valid because we have seen zero.

76
00:06:02,790 --> 00:06:11,490
To the left channel, which has been no tool, and it will set the protest to zero now different values

77
00:06:11,490 --> 00:06:12,510
of the cycle.

78
00:06:13,650 --> 00:06:16,190
Will turn on the lead with different priorities.

79
00:06:17,280 --> 00:06:25,680
Now this variable can be from zero up to 255 once that resolution used is eight bits.

80
00:06:26,220 --> 00:06:35,400
If we used a 10 bit resolution, it can go from zero up to 1024 or 1023 on.

81
00:06:35,730 --> 00:06:42,030
We already mentioned that you can choose as a union between one and up to 16.

82
00:06:42,810 --> 00:06:50,400
So the choice is yours, but you need to make sure that you are choosing a duty cycle that matches your

83
00:06:50,400 --> 00:06:51,030
resolution.

84
00:06:52,050 --> 00:06:58,910
So an eight bit resolution that cycle would be between zero and 125 to 155.

85
00:06:59,550 --> 00:07:09,930
OK, now that we are done with this, we can use the potential meter connected to the analogue pen from

86
00:07:09,930 --> 00:07:17,550
the previous lesson to control the brightness of that LEDs, or we can simply send values.

87
00:07:17,760 --> 00:07:19,740
Now to test this out?

88
00:07:20,370 --> 00:07:21,690
Let's complete the code.

89
00:07:22,680 --> 00:07:35,790
Let's first and the setup menu add cereal to begin and choose a moderate one hundred fifteen thousand

90
00:07:35,790 --> 00:07:36,600
two hundred.

91
00:07:37,990 --> 00:07:43,290
Then other delay as usual for one second

92
00:07:46,020 --> 00:07:46,950
after the delay.

93
00:07:47,130 --> 00:07:51,570
Let's write a sentence to make sure that everything is working correctly.

94
00:07:52,050 --> 00:08:01,470
Trend line and let's make this thing readable.

95
00:08:03,480 --> 00:08:07,710
OK, now we have the lead set up on the lid.

96
00:08:07,710 --> 00:08:15,180
See at the spin and we can use the lid see right up here.

97
00:08:16,860 --> 00:08:20,880
And the first value that will be written is zero so that it will be off.

98
00:08:21,900 --> 00:08:26,190
Now, inside the void loop, we can send other values.

99
00:08:27,540 --> 00:08:28,500
We can't send.

100
00:08:31,010 --> 00:08:33,500
Duty cycle, let's define duty cycle here.

101
00:08:35,900 --> 00:08:36,320
Plus.

102
00:08:38,610 --> 00:08:41,940
Equal +1, and let's add a delay.

103
00:08:47,760 --> 00:08:56,600
It's make it 15 milliseconds, okay, now, uh, let's move this line down here.

104
00:08:57,410 --> 00:08:58,700
It will start with zero.

105
00:08:58,940 --> 00:09:08,890
Then it will be +1 or let's make +10 and we'll keep moving until it reaches 235.

106
00:09:08,900 --> 00:09:12,830
We can add an if statement, but this this this called out.

107
00:09:15,940 --> 00:09:20,050
Let's first upload or verify it to make sure it doesn't have any errors.

108
00:09:21,250 --> 00:09:22,240
Let's save it.

109
00:09:25,360 --> 00:09:27,130
BW on this thing.

110
00:09:38,680 --> 00:09:41,140
OK, then combining now, let's upload the code.

111
00:09:47,970 --> 00:09:54,240
We should we should add a line to make sure that we will pretend that it's cycle.

112
00:10:02,230 --> 00:10:05,020
We want to combine the cold, but for now.

113
00:10:11,820 --> 00:10:17,160
Let's put it, compile it so that we can get that cycle here now.

114
00:10:18,700 --> 00:10:22,390
Let's recompile the code for the fight again.

115
00:10:30,830 --> 00:10:32,000
Now it's loaded.

116
00:11:13,250 --> 00:11:14,300
OK, now.

117
00:11:15,400 --> 00:11:23,740
As you can see, it went above 255 very fast, so we need to control this once the duty cycle reaches

118
00:11:26,240 --> 00:11:30,100
its cycle is of equal to 125.

119
00:11:30,730 --> 00:11:33,940
We need to reset to zero.

120
00:11:36,560 --> 00:11:38,270
Now, let's combine it again.

121
00:11:40,840 --> 00:11:41,920
Now, let's upload it.

122
00:12:00,300 --> 00:12:00,690
OK.

123
00:12:00,870 --> 00:12:01,290
Done.

124
00:12:01,560 --> 00:12:08,460
Now, as you can see, once it reaches 255, it resets to zero.

125
00:12:08,790 --> 00:12:16,230
And from your ISP bald, you can see that the built in led all accelerated that you are connecting is

126
00:12:16,230 --> 00:12:17,940
fading in and out.

127
00:12:18,480 --> 00:12:20,790
Using this very simple code.

128
00:12:21,930 --> 00:12:26,970
Now, now let's summarize what we did this last one.

129
00:12:27,120 --> 00:12:29,850
We have said the frequency to 5000.

130
00:12:30,330 --> 00:12:36,900
We have used the channel to be zero and we have chosen the resolution to be eight, which means that

131
00:12:36,900 --> 00:12:39,960
we have to cycle between zero and 255.

132
00:12:40,770 --> 00:12:45,990
We started with a duty cycle of zero and he reached out of the theater communication.

133
00:12:46,440 --> 00:12:48,190
Here we used new functions.

134
00:12:48,210 --> 00:12:54,510
Let's use it up to set up that BW frequency channel and resolution.

135
00:12:55,050 --> 00:13:03,220
And this lets you attach pin to attach the beat function to us and to a specific pin, which has been

136
00:13:03,220 --> 00:13:03,960
number two here.

137
00:13:05,730 --> 00:13:08,550
And the LCD right is basically like analog, right?

138
00:13:08,580 --> 00:13:15,510
It takes a channel and the duty cycle and try its value to that channel.

139
00:13:16,780 --> 00:13:24,750
Now in this photo, we have used the LED channel, which was proudly attached here to pin number tool

140
00:13:25,420 --> 00:13:26,500
and that you Typekit.

141
00:13:26,680 --> 00:13:29,320
And we kept increasing the cycle by 10.

142
00:13:30,780 --> 00:13:32,580
And printed on this here on a monitor.

143
00:13:33,060 --> 00:13:39,720
Now, once that dude cycle reaches 255, which is the limit here, we did that.

144
00:13:39,720 --> 00:13:42,870
I said the cycle to zero to repeat the process again.

145
00:13:43,950 --> 00:13:49,920
And that is how you can fit it using P.W. arm signal.

146
00:13:50,010 --> 00:13:51,990
You can apply this to any other thing.

147
00:13:52,560 --> 00:13:59,790
You can choose 10 bit resolution in that case, if you did choose 10 bit resolution.

148
00:14:01,380 --> 00:14:06,910
You will get values between zero and one thousand twenty three.

149
00:14:07,320 --> 00:14:14,310
So in that case, this if statement will be one thousand twenty three instead of a set of 255.

150
00:14:15,090 --> 00:14:15,790
That's it.

151
00:14:15,810 --> 00:14:21,550
I know that this was a long plus one, but I wanted to explain, uh, bw.

152
00:14:21,570 --> 00:14:23,130
I'm using an example.

153
00:14:23,430 --> 00:14:27,690
I hope that everything is now well explained to you.

154
00:14:27,720 --> 00:14:30,700
If you have any question regarding anything, you can ask.

155
00:14:30,720 --> 00:14:31,530
This is Ashraf.

156
00:14:32,220 --> 00:14:32,790
See you next.

157
00:14:33,210 --> 00:14:33,960
Happen happening.

158
00:14:35,880 --> 00:14:37,770
This is educational engineering team.

