Hello again we're now going to enter into another concept which is there on the Raspberry Pi say for
example we already saw how to blink Ellaby.
And also we saw how to control anality using an input button.
For now let's see for example if I want to reread the brightness of the elderly if I were to vary the
intensity of light which is we're just going to be displayed from the entity which means the current
which is going to come to be relative from one of the pins needs to be constantly.
It needs to be constantly changing.
Right.
So for example currently at the Elodie which we saw in the last program if you will have a look and
that's in Python treats.
You know we had written a program for planes so we fly open the blinking if you remember up in number
seven right PIN number seven I had defined it as an output pin and that PIN number seven I had given
an output of a high and low so high low high low high low.
I gave on number seven.
But now I don't want to give just a high and then a low.
No no no I don't want to do that.
I don't want to give high means high completely.
I would give varying voltage or if I want.
Basically I want to give all green signals such that the intensity of light that is coming off from
the Elodie would vary from low to high.
That's what I want.
So basically I did not want to use my pen as a digital pin any more but as an analog output print that
is what I want to use the P.W. and Benza.
All right so.
So how do we do it and how do I get to access this and how do I get to use it.
All right.
I understand that in detail as we as we start up with a new concept of speed WM DWM comes to our rescue
which I would call it pulse great modulation.
With modulation.
Right.
So for example you need to visualize what I'm going to see now.
All right.
Let's see if you want to switch on and off a light if you will to switch on and off an LCD or a light
which is there in your room.
You have a switch.
OK.
Switch on off on off when you switch when you make the switches on the light glows when you make the
switch is off.
The light goes off.
Right.
That is exactly what happens when we switch on and off and Elodie.
But now I want you to visualize something like this.
Let's say for example you were given a fan to control.
You were given a phantom control.
And you know you want to vary the speed of the fan.
But let's say sadly you will not given the regulator regulator to control the speed of the fan is not
given to you but you still have a switch.
Ok you're just given the switch which is to switch off the fan and which is to switch on the fan.
That's it.
What you are told to control the speed of the fan.
How would you control it.
How would you control the speed of the fan when you have to control using a switch.
How would you do that.
This is where we.
This is where you understand the concept of speed up.
Let me say for example the minute they switch off the minute they switch off though fine button Kevin
I switch up the fan what does the fan become.
The speed of the fan does it become zero instantly.
No it does not become zero instantly.
It goes down slow and then it will become zero gradual.
Right now whatever it becomes a bit slow and it's about you know where it's become it's going make it
on again.
Then I don't allow it to go back to the Fosdike.
I don't want it to go back to the fast.
If I keep switching it on and off on and off on and off on and off in such a way if I keep switching
the fan button on and off in such a way that the fan speed is neither completely high nor is it completely
low.
Can I see I have attained some control of speed of the fan.
Yes.
Even though it's mechanically I have attained to control the speed of the fan or try to make it a bit
less.
The fan will either be off nor will it be on but it will be at a medium speed probably at a medium speed
based on the number of times you switch on and off based on the number of times you switch on and off
if you switch it on for a long time and all for a short time then what will happen.
The fan will be rotating at a higher speed.
If you keep it all for a long time and on for a short time it will be rotating at a shorter speed.
Right.
So you are basically VTB on time on time and the off time.
OK so you're getting the on time and the off thing.
Now this is exactly what pilots with moderation does it fix and analog log output in such a way that
you give a pulse which is high and give a pulse which is low very fast.
You get one or the other on a same pin.
So let's say if you have taken a particular plane let's say one of the cheapie pins.
Of course not all GPI opens DPW him specifically 12:18 13 and 19.
These are the ones which are used for P.W. and 12 18 13 and 19.
So these are the pins which are basically used for pucks with moderation.
OK it's coming to that a bit later but for now let's say for example on this particular pin instead
of giving a high and instead of giving a lot what if.
What if I could do something like giving a high and low or giving a high low high low hi hi hi Lou at
a very fast rate.
Can you imagine the voltage which comes out from that particular pin.
Let's see a pin number 12 PIN number 12.
I don't give a hide from it not wake you will know from it but I give a high Ohio High Low halo halo
such that the voltage that is coming out from PIN number 12 is no longer going to be Meador maximum
nor is it going to be zero.
It is going to be somewhere in between.
And that is going to be valey by the weight of the on time and the offtake line.
So the time is or is more then the wordage will be more more closer to the maximum if the off time is
more the voltage would be more close to the zero grade.
So we need to be the the of the world.
Hence no one as adults with the money are able to understand but with moderation.
So we are now going to understand how to give a pulse with our relations say no on the Raspberry Pi.
All right.
So we'll open a new file.
We are going to save it.
Let's let's save it as Paul sweat.
OK.
And we're going to start writing the code for pulse with modulation.
But before that let's have a look at the pins which pins do we connect to.
All right.
Let's see which pin should I use.
I'd say PIN number 12 18 13 and 19 were the ideal pins that can be used for pulse with one mission 12
18 and these are the G.P.O. prints not the board numbering but the Broadcom numbering 12:18 13:19 Let's
have a look at where the spin configuration lies.
So I just minimized my Raspberry Pi screen which is running on my VNC.
I just minimize this and I'm going to just see the rest pretty PI pin configuration.
So as you can see the raspberry pipe in God's arrogation I have from pin number 1 to pin number 40 right.
So this is my pin 1 and 2 pin 3 and 4 and 5 and 6 0 1 1 1 2 3 and 4 and 5 and 6 and 7 8.
All right but that's not the board that the board numbering that's not the Broadcom numbering.
I want to go for the Broadcom numbering where I need the pin number.
All
I say pin number 12 and number 12 that is Asare pin number GPI or 12 GPI or Twelvers GPI or 12 GPA.
12 is this GPI 12 that is spin number board number 32.
That is GPI open.
Then you have a GPO 18 GPA 18 is nothing but the board number 12 itself.
Right.
And you have another one that is GPO 13 G.P.O. 13 that is £33 number 33.
And then you have a GPI or 19 which is print number 35.
So this is more easier for us to understand just two wins away from the last two pins away from the
last.
If this is 40 somewhere somewhere here G.P.O. 19 is certified so we go for GPI on 19 and we'll start
programming in that particular fashion.
All right let's get back to our code.
And here we are.
Let's start coding on it.
OK so regarding your to use the number 19.
Now what are you going to do is we need to generate the P.W. I'm using using a python code.
All right so we can do something like this import of scores if you remember.
I need to import the pie or GPI or library and I'm going to use it as.
Let me see I'm going to use it as GPI a big one.
All right.
I can import from time.
I'm going to import sleep right.
Say for example whenever I want to cause it really to happen I can do that right.
OK so all I can do is I need to say you know GPI ordered set maut.
I have to say which Pridden contract been more than my using.
Am I using the cheap CIO GPI board or am I using the Broadcom configuration.
Let's use the Broadcom conflagration that is GPI or got VCM Broadcom right.
Broadcom.
And I'm going to use PIN number 19 GPO 19 to be specific.
All right.
So you got a Broadcom and then I'm going to call the set up function which is going to say PIN number
19 right.
That is UKIO that Broadcom configuration pin number that is 19 that is UKIO 19.
You need to act as an output.
And of course you're giving an output which is going to really interact as an output pin.
All right.
Now this much is already understood we're understood at last lost the last lecture it says.
All right.
Now we need to go for something like after said mode and after doing set up we to create we need to
create an PWO object we need to create a P.W. object.
That's what we need to do right.