WEBVTT 00:00.330 --> 00:08.340 Hello again we're now going to enter into another concept which is there on the Raspberry Pi say for 00:08.340 --> 00:11.470 example we already saw how to blink Ellaby. 00:11.580 --> 00:15.640 And also we saw how to control anality using an input button. 00:15.920 --> 00:23.190 For now let's see for example if I want to reread the brightness of the elderly if I were to vary the 00:23.190 --> 00:28.350 intensity of light which is we're just going to be displayed from the entity which means the current 00:28.350 --> 00:35.000 which is going to come to be relative from one of the pins needs to be constantly. 00:35.610 --> 00:37.690 It needs to be constantly changing. 00:37.740 --> 00:38.380 Right. 00:38.400 --> 00:44.940 So for example currently at the Elodie which we saw in the last program if you will have a look and 00:45.180 --> 00:47.230 that's in Python treats. 00:47.360 --> 00:53.610 You know we had written a program for planes so we fly open the blinking if you remember up in number 00:54.210 --> 01:03.240 seven right PIN number seven I had defined it as an output pin and that PIN number seven I had given 01:03.240 --> 01:07.220 an output of a high and low so high low high low high low. 01:07.410 --> 01:09.180 I gave on number seven. 01:09.300 --> 01:13.270 But now I don't want to give just a high and then a low. 01:13.290 --> 01:14.850 No no no I don't want to do that. 01:14.850 --> 01:18.130 I don't want to give high means high completely. 01:18.360 --> 01:21.250 I would give varying voltage or if I want. 01:21.270 --> 01:29.280 Basically I want to give all green signals such that the intensity of light that is coming off from 01:29.280 --> 01:32.860 the Elodie would vary from low to high. 01:33.030 --> 01:34.230 That's what I want. 01:34.230 --> 01:42.380 So basically I did not want to use my pen as a digital pin any more but as an analog output print that 01:42.440 --> 01:45.180 is what I want to use the P.W. and Benza. 01:45.240 --> 01:46.350 All right so. 01:46.440 --> 01:52.980 So how do we do it and how do I get to access this and how do I get to use it. 01:53.100 --> 01:53.500 All right. 01:53.530 --> 02:02.520 I understand that in detail as we as we start up with a new concept of speed WM DWM comes to our rescue 02:02.940 --> 02:07.230 which I would call it pulse great modulation. 02:07.440 --> 02:08.540 With modulation. 02:08.700 --> 02:09.160 Right. 02:09.300 --> 02:13.520 So for example you need to visualize what I'm going to see now. 02:13.530 --> 02:14.060 All right. 02:14.250 --> 02:20.520 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 02:20.520 --> 02:21.860 which is there in your room. 02:21.930 --> 02:23.280 You have a switch. 02:23.520 --> 02:24.480 OK. 02:24.720 --> 02:31.560 Switch on off on off when you switch when you make the switches on the light glows when you make the 02:31.560 --> 02:32.420 switch is off. 02:32.430 --> 02:34.050 The light goes off. 02:34.050 --> 02:34.820 Right. 02:34.860 --> 02:38.990 That is exactly what happens when we switch on and off and Elodie. 02:39.030 --> 02:41.250 But now I want you to visualize something like this. 02:41.250 --> 02:44.680 Let's say for example you were given a fan to control. 02:44.700 --> 02:46.620 You were given a phantom control. 02:46.890 --> 02:51.970 And you know you want to vary the speed of the fan. 02:52.380 --> 02:59.310 But let's say sadly you will not given the regulator regulator to control the speed of the fan is not 02:59.310 --> 03:01.980 given to you but you still have a switch. 03:02.190 --> 03:07.830 Ok you're just given the switch which is to switch off the fan and which is to switch on the fan. 03:07.830 --> 03:08.550 That's it. 03:08.580 --> 03:11.090 What you are told to control the speed of the fan. 03:11.190 --> 03:12.300 How would you control it. 03:12.300 --> 03:17.850 How would you control the speed of the fan when you have to control using a switch. 03:17.850 --> 03:19.190 How would you do that. 03:19.200 --> 03:20.660 This is where we. 03:20.790 --> 03:23.300 This is where you understand the concept of speed up. 03:23.550 --> 03:30.040 Let me say for example the minute they switch off the minute they switch off though fine button Kevin 03:30.100 --> 03:33.520 I switch up the fan what does the fan become. 03:33.540 --> 03:36.540 The speed of the fan does it become zero instantly. 03:36.570 --> 03:40.160 No it does not become zero instantly. 03:40.200 --> 03:45.250 It goes down slow and then it will become zero gradual. 03:45.270 --> 03:50.400 Right now whatever it becomes a bit slow and it's about you know where it's become it's going make it 03:50.400 --> 03:51.370 on again. 03:51.600 --> 03:55.050 Then I don't allow it to go back to the Fosdike. 03:55.200 --> 03:57.460 I don't want it to go back to the fast. 03:57.720 --> 04:03.540 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 04:03.540 --> 04:12.630 the fan button on and off in such a way that the fan speed is neither completely high nor is it completely 04:12.630 --> 04:13.370 low. 04:13.440 --> 04:19.770 Can I see I have attained some control of speed of the fan. 04:20.220 --> 04:20.810 Yes. 04:20.880 --> 04:26.880 Even though it's mechanically I have attained to control the speed of the fan or try to make it a bit 04:26.880 --> 04:27.740 less. 04:27.750 --> 04:33.630 The fan will either be off nor will it be on but it will be at a medium speed probably at a medium speed 04:33.630 --> 04:40.770 based on the number of times you switch on and off based on the number of times you switch on and off 04:40.890 --> 04:47.350 if you switch it on for a long time and all for a short time then what will happen. 04:47.700 --> 04:50.400 The fan will be rotating at a higher speed. 04:50.490 --> 04:57.120 If you keep it all for a long time and on for a short time it will be rotating at a shorter speed. 04:57.120 --> 04:57.690 Right. 04:57.780 --> 05:05.180 So you are basically VTB on time on time and the off time. 05:05.400 --> 05:08.200 OK so you're getting the on time and the off thing. 05:08.220 --> 05:15.360 Now this is exactly what pilots with moderation does it fix and analog log output in such a way that 05:15.600 --> 05:22.050 you give a pulse which is high and give a pulse which is low very fast. 05:22.140 --> 05:24.580 You get one or the other on a same pin. 05:24.630 --> 05:29.380 So let's say if you have taken a particular plane let's say one of the cheapie pins. 05:29.460 --> 05:35.070 Of course not all GPI opens DPW him specifically 12:18 13 and 19. 05:35.070 --> 05:42.730 These are the ones which are used for P.W. and 12 18 13 and 19. 05:42.780 --> 05:46.990 So these are the pins which are basically used for pucks with moderation. 05:47.160 --> 05:53.070 OK it's coming to that a bit later but for now let's say for example on this particular pin instead 05:53.070 --> 05:57.060 of giving a high and instead of giving a lot what if. 05:57.080 --> 06:07.680 What if I could do something like giving a high and low or giving a high low high low hi hi hi Lou at 06:07.680 --> 06:09.380 a very fast rate. 06:09.420 --> 06:12.690 Can you imagine the voltage which comes out from that particular pin. 06:12.700 --> 06:14.970 Let's see a pin number 12 PIN number 12. 06:15.120 --> 06:20.940 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 06:21.150 --> 06:27.180 such that the voltage that is coming out from PIN number 12 is no longer going to be Meador maximum 06:27.660 --> 06:30.120 nor is it going to be zero. 06:30.270 --> 06:32.870 It is going to be somewhere in between. 06:32.910 --> 06:41.010 And that is going to be valey by the weight of the on time and the offtake line. 06:41.010 --> 06:50.040 So the time is or is more then the wordage will be more more closer to the maximum if the off time is 06:50.040 --> 06:53.860 more the voltage would be more close to the zero grade. 06:54.030 --> 06:58.840 So we need to be the the of the world. 06:59.070 --> 07:05.460 Hence no one as adults with the money are able to understand but with moderation. 07:05.460 --> 07:12.420 So we are now going to understand how to give a pulse with our relations say no on the Raspberry Pi. 07:12.420 --> 07:12.800 All right. 07:12.800 --> 07:14.130 So we'll open a new file. 07:14.160 --> 07:15.440 We are going to save it. 07:15.670 --> 07:20.640 Let's let's save it as Paul sweat. 07:23.500 --> 07:23.960 OK. 07:23.970 --> 07:27.810 And we're going to start writing the code for pulse with modulation. 07:27.810 --> 07:31.740 But before that let's have a look at the pins which pins do we connect to. 07:32.000 --> 07:32.820 All right. 07:33.170 --> 07:35.310 Let's see which pin should I use. 07:35.330 --> 07:45.050 I'd say PIN number 12 18 13 and 19 were the ideal pins that can be used for pulse with one mission 12 07:45.080 --> 07:51.260 18 and these are the G.P.O. prints not the board numbering but the Broadcom numbering 12:18 13:19 Let's 07:51.260 --> 07:54.490 have a look at where the spin configuration lies. 07:54.500 --> 08:00.580 So I just minimized my Raspberry Pi screen which is running on my VNC. 08:00.950 --> 08:05.480 I just minimize this and I'm going to just see the rest pretty PI pin configuration. 08:05.480 --> 08:11.920 So as you can see the raspberry pipe in God's arrogation I have from pin number 1 to pin number 40 right. 08:11.930 --> 08:19.870 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. 08:20.030 --> 08:25.010 All right but that's not the board that the board numbering that's not the Broadcom numbering. 08:25.100 --> 08:29.900 I want to go for the Broadcom numbering where I need the pin number. 08:29.900 --> 08:30.300 All 08:33.030 --> 08:42.640 I say pin number 12 and number 12 that is Asare pin number GPI or 12 GPI or Twelvers GPI or 12 GPA. 08:42.640 --> 08:47.490 12 is this GPI 12 that is spin number board number 32. 08:47.700 --> 08:49.390 That is GPI open. 08:49.470 --> 08:55.660 Then you have a GPO 18 GPA 18 is nothing but the board number 12 itself. 08:56.040 --> 08:56.790 Right. 08:57.130 --> 09:05.360 And you have another one that is GPO 13 G.P.O. 13 that is £33 number 33. 09:05.520 --> 09:08.810 And then you have a GPI or 19 which is print number 35. 09:08.820 --> 09:17.100 So this is more easier for us to understand just two wins away from the last two pins away from the 09:17.100 --> 09:18.030 last. 09:18.130 --> 09:25.680 If this is 40 somewhere somewhere here G.P.O. 19 is certified so we go for GPI on 19 and we'll start 09:25.680 --> 09:27.810 programming in that particular fashion. 09:27.810 --> 09:30.590 All right let's get back to our code. 09:30.780 --> 09:33.150 And here we are. 09:33.870 --> 09:35.300 Let's start coding on it. 09:35.520 --> 09:38.050 OK so regarding your to use the number 19. 09:38.230 --> 09:44.760 Now what are you going to do is we need to generate the P.W. I'm using using a python code. 09:44.760 --> 09:48.640 All right so we can do something like this import of scores if you remember. 09:48.660 --> 09:54.860 I need to import the pie or GPI or library and I'm going to use it as. 09:54.870 --> 09:58.570 Let me see I'm going to use it as GPI a big one. 09:58.570 --> 09:59.210 All right. 09:59.220 --> 10:00.970 I can import from time. 10:00.990 --> 10:03.270 I'm going to import sleep right. 10:03.360 --> 10:09.470 Say for example whenever I want to cause it really to happen I can do that right. 10:09.960 --> 10:16.900 OK so all I can do is I need to say you know GPI ordered set maut. 10:17.220 --> 10:21.210 I have to say which Pridden contract been more than my using. 10:21.240 --> 10:29.830 Am I using the cheap CIO GPI board or am I using the Broadcom configuration. 10:29.830 --> 10:35.480 Let's use the Broadcom conflagration that is GPI or got VCM Broadcom right. 10:35.520 --> 10:36.280 Broadcom. 10:36.280 --> 10:42.480 And I'm going to use PIN number 19 GPO 19 to be specific. 10:42.570 --> 10:43.100 All right. 10:43.260 --> 10:50.220 So you got a Broadcom and then I'm going to call the set up function which is going to say PIN number 10:51.150 --> 10:52.860 19 right. 10:52.890 --> 10:59.520 That is UKIO that Broadcom configuration pin number that is 19 that is UKIO 19. 10:59.580 --> 11:02.370 You need to act as an output. 11:02.400 --> 11:03.470 You need to act as an output. 11:03.490 --> 11:09.080 And of course you're giving an output which is going to really interact as an output pin. 11:09.120 --> 11:09.850 All right. 11:09.870 --> 11:16.920 Now this much is already understood we're understood at last lost the last lecture it says. 11:17.160 --> 11:17.700 All right. 11:17.700 --> 11:25.710 Now we need to go for something like after said mode and after doing set up we to create we need to 11:25.710 --> 11:32.200 create an PWO object we need to create a P.W. object. 11:32.280 --> 11:34.170 That's what we need to do right.