Hello and welcome.
In this lesson, we are going to take on the P.W. ambitions of the ESB board.
All 36 of the ESB 32 general purpose Input-Output Benz has a P.W. arm capability.
This is a really great thing.
But we must use more complex code to reach the same result on other pins.
So let's put it on one of the general purpose, Input-Output with a P.W. output signal.
Now if you went to this schematic all this pin out for various people, you can see that all of these
pins can be used to generate P.W. arm signals.
The first thing that you need to think about when programming a P.W. on the signal is its frequency.
You need to retrieve that signal at a certain or specific frequency.
We will use a value of 5000 hertz.
That works fine with our lead.
We must also specify that it P.W. and channel and the resolution of the BW and duty cycle.
I want.
Explain that BWR, because you must have some basic knowledge about BW on signals, but what it takes
is also the ocean, a channel and a frequency.
So after specifying that you to cycle using the solution and the frequency on the channel, we can start
programming.
We can choose a channel from zero to 15 and a resolution between one and 16 bits.
We will use Channel zero and a resolution of eight bits.
So let's get started.
That's good, according to your thumbnail sketch.
And here's a new sketch.
Let's define some variables.
First, we need to define that frequency and frequency.
And let's make it 5000.
Then we need the left channel.
Let's make it zero and we need the resolution.
And let's make it eight now.
Let's use that general purpose, Input-Output win.
Number two, where we have our lead on our external LED connected or at best.
It's also has a built in lid that can be used.
So these parameters must be defined inside the setup function.
So let's go on why this gold?
Now what we are going to write in inside the setup function won't be something we are used to, while
going to likely see a dustbin and Lid C sit up.
Now the Let's See attachment and let's use it up.
There are basically functions for the BW arm configuration.
They are very similar to analog write function and Arduino.
So now the DSP.
Doesn't support another great function, but it does support a much better one, which is the one that
we already mentioned.
Let's see right there.
Let's see.
A light function is very similar to another light.
It also requires two parameters that BW channel that we want to write about Utah and the BW value.
We want to write to the selected channel.
Now, let's first finish the setup function now the let's see setup function.
Will take three parameters.
The first one will be the child.
The second one will be the frequency.
The third one will be the resolution, which we already defined up there.
Next, we are going to assign a lead to that channel, so let see at that pin.
Now the lid pin we already chose is two and we want to attach it to that channel that we have chosen.
This is it.
This is how you finish setting up that BW, um, frequency resolution and channel and how you can attach
it to any output pin.
Now to turn the lid, which is connected to PIN number two using the lid channel output from the VW
signal.
We need to set a specific brightness now to turn it on or off.
We must define the duty cycle, for example, turn off the lid.
That cycle must be zero.
And the function lid see right that we already mentioned can be used inside the loop to set the brightness
to zero.
Now.
We can use that function right now.
That's right.
Let's see.
Right.
It's exactly like analog, right?
And it takes two parameters.
The first one is the lead channel, which is this variable.
And the second one is the duty cycle.
Now you can add in duty cycle here and add zero.
This will turn off valid because we have seen zero.
To the left channel, which has been no tool, and it will set the protest to zero now different values
of the cycle.
Will turn on the lead with different priorities.
Now this variable can be from zero up to 255 once that resolution used is eight bits.
If we used a 10 bit resolution, it can go from zero up to 1024 or 1023 on.
We already mentioned that you can choose as a union between one and up to 16.
So the choice is yours, but you need to make sure that you are choosing a duty cycle that matches your
resolution.
So an eight bit resolution that cycle would be between zero and 125 to 155.
OK, now that we are done with this, we can use the potential meter connected to the analogue pen from
the previous lesson to control the brightness of that LEDs, or we can simply send values.
Now to test this out?
Let's complete the code.
Let's first and the setup menu add cereal to begin and choose a moderate one hundred fifteen thousand
two hundred.
Then other delay as usual for one second
after the delay.
Let's write a sentence to make sure that everything is working correctly.
Trend line and let's make this thing readable.
OK, now we have the lead set up on the lid.
See at the spin and we can use the lid see right up here.
And the first value that will be written is zero so that it will be off.
Now, inside the void loop, we can send other values.
We can't send.
Duty cycle, let's define duty cycle here.
Plus.
Equal +1, and let's add a delay.
It's make it 15 milliseconds, okay, now, uh, let's move this line down here.
It will start with zero.
Then it will be +1 or let's make +10 and we'll keep moving until it reaches 235.
We can add an if statement, but this this this called out.
Let's first upload or verify it to make sure it doesn't have any errors.
Let's save it.
BW on this thing.
OK, then combining now, let's upload the code.
We should we should add a line to make sure that we will pretend that it's cycle.
We want to combine the cold, but for now.
Let's put it, compile it so that we can get that cycle here now.
Let's recompile the code for the fight again.
Now it's loaded.
OK, now.
As you can see, it went above 255 very fast, so we need to control this once the duty cycle reaches
its cycle is of equal to 125.
We need to reset to zero.
Now, let's combine it again.
Now, let's upload it.
OK.
Done.
Now, as you can see, once it reaches 255, it resets to zero.
And from your ISP bald, you can see that the built in led all accelerated that you are connecting is
fading in and out.
Using this very simple code.
Now, now let's summarize what we did this last one.
We have said the frequency to 5000.
We have used the channel to be zero and we have chosen the resolution to be eight, which means that
we have to cycle between zero and 255.
We started with a duty cycle of zero and he reached out of the theater communication.
Here we used new functions.
Let's use it up to set up that BW frequency channel and resolution.
And this lets you attach pin to attach the beat function to us and to a specific pin, which has been
number two here.
And the LCD right is basically like analog, right?
It takes a channel and the duty cycle and try its value to that channel.
Now in this photo, we have used the LED channel, which was proudly attached here to pin number tool
and that you Typekit.
And we kept increasing the cycle by 10.
And printed on this here on a monitor.
Now, once that dude cycle reaches 255, which is the limit here, we did that.
I said the cycle to zero to repeat the process again.
And that is how you can fit it using P.W. arm signal.
You can apply this to any other thing.
You can choose 10 bit resolution in that case, if you did choose 10 bit resolution.
You will get values between zero and one thousand twenty three.
So in that case, this if statement will be one thousand twenty three instead of a set of 255.
That's it.
I know that this was a long plus one, but I wanted to explain, uh, bw.
I'm using an example.
I hope that everything is now well explained to you.
If you have any question regarding anything, you can ask.
This is Ashraf.
See you next.
Happen happening.
This is educational engineering team.