1 00:00:01,800 --> 00:00:03,930 Hello. In this exercise we are going 2 00:00:03,930 --> 00:00:06,540 to learn how to use the LCD 3 00:00:06,750 --> 00:00:08,670 screen and 4 00:00:09,340 --> 00:00:11,940 we are going to connect it to the arduino board using 5 00:00:12,000 --> 00:00:14,160 again a serial connection there are 6 00:00:14,220 --> 00:00:16,530 serial connection with the computers but here 7 00:00:16,800 --> 00:00:19,320 we're going to use a specific serial connection 8 00:00:19,830 --> 00:00:22,050 and then we can find here ok 9 00:00:22,380 --> 00:00:22,800 here 10 00:00:24,120 --> 00:00:25,860 we can see the digital connectors we 11 00:00:25,860 --> 00:00:27,701 already know then and if we moved 12 00:00:27,701 --> 00:00:29,130 to the left we would find this 13 00:00:29,130 --> 00:00:31,767 one that is called the SCL 14 00:00:31,770 --> 00:00:33,120 and is one that is called the SDA 15 00:00:33,134 --> 00:00:36,720 ok these two connectors 16 00:00:36,720 --> 00:00:39,857 these two pins are used to 17 00:00:39,857 --> 00:00:42,720 transmit serial information and we can use 18 00:00:42,720 --> 00:00:44,160 them to send information to 19 00:00:44,160 --> 00:00:46,860 different devices not just one, so 20 00:00:46,890 --> 00:00:48,450 for example here we have the SCL 21 00:00:48,510 --> 00:00:51,090 connection, the yellow wire and 22 00:00:51,090 --> 00:00:52,830 here you can see that is connected 23 00:00:52,830 --> 00:00:54,690 to the SCL connection to 24 00:00:54,750 --> 00:00:56,970 the screen and here you 25 00:00:56,970 --> 00:00:58,920 can see that the yellow wire continues 26 00:00:59,190 --> 00:01:01,200 and goes to a new SCL 27 00:01:01,200 --> 00:01:03,120 connection okay so the two of them 28 00:01:03,180 --> 00:01:04,050 are using the same 29 00:01:04,319 --> 00:01:06,840 wire the same connection and the same 30 00:01:06,840 --> 00:01:08,820 for the SDA connection the 31 00:01:08,880 --> 00:01:09,630 green wire 32 00:01:10,800 --> 00:01:13,530 it is connected from the arduino board to 33 00:01:13,860 --> 00:01:15,660 the first one and then to the 34 00:01:15,660 --> 00:01:18,210 second okay and we also have two 35 00:01:18,780 --> 00:01:20,250 other connectors ground 36 00:01:21,360 --> 00:01:23,520 that is connected to ground obviously 37 00:01:24,780 --> 00:01:27,510 the power source there and red green 38 00:01:27,540 --> 00:01:30,000 and the red wire that is connected 39 00:01:30,330 --> 00:01:31,200 okay five volts 40 00:01:32,610 --> 00:01:34,150 and this is the way we connect 41 00:01:34,343 --> 00:01:35,700 different 42 00:01:37,050 --> 00:01:39,270 screens, LCD screens, to the computer 43 00:01:39,750 --> 00:01:41,460 To the arduino board, I'm sorry. We can 44 00:01:41,460 --> 00:01:43,320 connect several of them here we only 45 00:01:43,320 --> 00:01:45,360 have connected two but if we had 46 00:01:45,360 --> 00:01:47,100 a third one we would be able 47 00:01:47,100 --> 00:01:48,480 to connect it the same way 48 00:01:48,480 --> 00:01:51,360 okay just continuing the different wires 49 00:01:52,110 --> 00:01:55,470 each LCD is going to be 50 00:01:55,470 --> 00:01:56,040 defined 51 00:01:56,910 --> 00:01:58,260 click on it we want to be 52 00:01:58,260 --> 00:02:00,660 defined by the address, for example 53 00:02:00,660 --> 00:02:02,460 this one, the address for the first one 54 00:02:02,460 --> 00:02:05,460 is thirty four and the address for 55 00:02:05,482 --> 00:02:07,980 the second one is thirty two ok 56 00:02:08,699 --> 00:02:10,620 and there's another parameter here, that is 57 00:02:10,620 --> 00:02:14,220 the protocol kind of language we're 58 00:02:14,280 --> 00:02:16,440 going to use to program 59 00:02:16,440 --> 00:02:19,740 our LCD screen ok we 60 00:02:19,760 --> 00:02:21,450 use this protocol and the same 61 00:02:23,550 --> 00:02:25,290 and it is the same for the two 62 00:02:25,290 --> 00:02:27,510 of them okay different addresses but same 63 00:02:27,510 --> 00:02:30,000 protocol and we need to use different 64 00:02:30,000 --> 00:02:32,760 addresses because using different addresses the arduino 65 00:02:32,760 --> 00:02:34,770 board will be able to 66 00:02:34,886 --> 00:02:37,303 to know to which one is speaking 67 00:02:37,303 --> 00:02:39,360 or from which one is 68 00:02:39,360 --> 00:02:42,300 receiving information okay 69 00:02:42,780 --> 00:02:45,180 that's why we need different addresses okay 70 00:02:45,815 --> 00:02:48,360 this is the way we connect different 71 00:02:48,360 --> 00:02:51,390 devices. The LCD screen can be 72 00:02:51,390 --> 00:02:54,660 found here if you type LCD here 73 00:02:54,660 --> 00:02:57,306 there are two devices and the 74 00:02:57,330 --> 00:02:59,280 one we use is the I2C 75 00:02:59,280 --> 00:03:01,320 because I2C is the 76 00:03:01,320 --> 00:03:02,880 serial protocol we are going to 77 00:03:02,880 --> 00:03:03,990 use to connect it 78 00:03:05,340 --> 00:03:09,750 eh ok so what about programming it 79 00:03:11,700 --> 00:03:15,120 I want to open the block window 80 00:03:16,451 --> 00:03:18,840 to make it bigger easier 81 00:03:20,250 --> 00:03:22,980 to have a look at the codes. The first thing 82 00:03:22,980 --> 00:03:24,780 we need to look at every code 83 00:03:25,140 --> 00:03:26,790 every block we are going to use is in 84 00:03:26,790 --> 00:03:29,250 the blue library because the arduino 85 00:03:29,250 --> 00:03:32,250 I mean the LCD screen will 86 00:03:32,250 --> 00:03:34,380 receive information from the arduino board 87 00:03:34,380 --> 00:03:36,480 that's why we are using output blocks 88 00:03:36,810 --> 00:03:39,248 all of them are blue and 89 00:03:40,110 --> 00:03:40,530 here 90 00:03:41,820 --> 00:03:44,190 because we have two screens we are going to 91 00:03:44,190 --> 00:03:46,740 to set the two of them 92 00:03:47,520 --> 00:03:49,500 and we are going to use this block 93 00:03:49,560 --> 00:03:52,980 "configurar tipo de LCD" 94 00:03:52,980 --> 00:03:55,410 for example, address thirty two 95 00:03:55,410 --> 00:03:58,680 will be number one so thirty two 96 00:03:58,680 --> 00:04:00,240 this one is meant to be 97 00:04:00,420 --> 00:04:01,920 number one the lower 98 00:04:01,950 --> 00:04:02,280 one 99 00:04:03,360 --> 00:04:04,470 and 100 00:04:06,040 --> 00:04:08,760 and the lower one is going to be 101 00:04:08,760 --> 00:04:11,730 thirty four number two 102 00:04:11,730 --> 00:04:13,770 okay and we use this protocol 103 00:04:14,186 --> 00:04:15,510 the same protocol is here 104 00:04:16,564 --> 00:04:18,690 because both of them 105 00:04:20,490 --> 00:04:22,440 the LCD screen under the arduino 106 00:04:22,440 --> 00:04:24,014 board, both of them they need 107 00:04:24,014 --> 00:04:26,340 to speak the same language so number 108 00:04:26,340 --> 00:04:28,680 one will use this language to communicate 109 00:04:28,731 --> 00:04:30,660 with the arduino board is going to 110 00:04:30,660 --> 00:04:33,540 be connected in address thirty two the 111 00:04:33,540 --> 00:04:35,280 second one same protocol and thity four 112 00:04:35,280 --> 00:04:36,780 so this way we can 113 00:04:38,160 --> 00:04:40,770 we can connect several devices 114 00:04:41,220 --> 00:04:44,370 there are addresses from thirty 115 00:04:44,370 --> 00:04:45,780 two to thirty nine so we can 116 00:04:45,780 --> 00:04:49,380 connect eight different devices using this protocol ok 117 00:04:52,020 --> 00:04:55,710 and so be careful with addresses 118 00:04:55,710 --> 00:04:56,880 ok they are very important 119 00:04:59,610 --> 00:05:02,210 what other blocks do we have? 120 00:05:02,820 --> 00:05:03,630 we have 121 00:05:05,130 --> 00:05:05,700 this block 122 00:05:12,150 --> 00:05:15,960 first of all, in LCD one or two or 123 00:05:15,960 --> 00:05:16,620 three or four 124 00:05:17,970 --> 00:05:19,830 we can do 125 00:05:19,922 --> 00:05:23,130 different things for example we can switch 126 00:05:23,130 --> 00:05:25,230 the light on you can erase the 127 00:05:25,230 --> 00:05:29,100 screen, switch the light off what happens 128 00:05:29,100 --> 00:05:30,630 if we switch 129 00:05:30,646 --> 00:05:32,400 the light on for the first one 130 00:05:32,850 --> 00:05:37,920 if we start the simulation 131 00:05:37,920 --> 00:05:39,750 the first one is on but not the second one 132 00:05:39,750 --> 00:05:40,830 and that's ok 133 00:05:42,000 --> 00:05:43,140 we can change 134 00:05:44,140 --> 00:05:46,099 we can switch the second one on 135 00:05:46,120 --> 00:05:47,760 and we simulate it again 136 00:05:49,620 --> 00:05:51,990 an now is number two is on 137 00:05:51,991 --> 00:05:54,390 before 138 00:05:54,390 --> 00:05:57,810 continuing with the blue blocks 139 00:05:57,810 --> 00:05:59,190 I want you to realize that we are 140 00:05:59,190 --> 00:06:01,990 using this kind of loop 141 00:06:02,000 --> 00:06:03,200 not a real loop 142 00:06:03,200 --> 00:06:04,440 "al iniciar" 143 00:06:04,440 --> 00:06:06,300 this part of the program and this one 144 00:06:06,360 --> 00:06:08,370 "siempre", forever, is a real 145 00:06:08,460 --> 00:06:11,040 loop and not the first one. These are 146 00:06:11,040 --> 00:06:12,840 the two parts of the program 147 00:06:13,230 --> 00:06:17,310 in this new version of Tinkercad 148 00:06:18,780 --> 00:06:21,570 these two blogs have been included this 149 00:06:21,570 --> 00:06:23,490 one is the setup, "al iniciar" means 150 00:06:23,490 --> 00:06:24,750 that they are going to 151 00:06:24,750 --> 00:06:27,570 be run just once and then "siempre" 152 00:06:27,570 --> 00:06:28,560 means 153 00:06:28,590 --> 00:06:29,940 this is the real code i mean 154 00:06:29,940 --> 00:06:31,200 the part of the program that will 155 00:06:31,200 --> 00:06:33,400 be repeated again and again so 156 00:06:33,380 --> 00:06:35,700 "al iniciar" we are using 157 00:06:35,940 --> 00:06:37,710 these two blocks "configurar LCD" 158 00:06:37,710 --> 00:06:39,840 here because we we only need to 159 00:06:39,840 --> 00:06:41,730 set it up once and no more than that 160 00:06:42,480 --> 00:06:44,100 and the rest of the code 161 00:06:44,100 --> 00:06:45,630 that will be repeated again and again 162 00:06:45,630 --> 00:06:48,720 is here, so 163 00:06:49,660 --> 00:06:54,300 I'll go back to "siempre", forever, and for example 164 00:06:54,330 --> 00:06:56,520 we can switch the light on 165 00:06:57,030 --> 00:06:59,970 we can also erase the screen ok 166 00:07:00,750 --> 00:07:01,980 we are going to erase the screen later 167 00:07:01,986 --> 00:07:03,900 but for the moment we are going 168 00:07:03,900 --> 00:07:06,780 to print a character for example we are 169 00:07:06,780 --> 00:07:08,100 going to print, we are going to 170 00:07:08,100 --> 00:07:08,880 switch number 171 00:07:08,940 --> 00:07:10,950 one on just a light ok you 172 00:07:10,950 --> 00:07:12,450 you can print things if the 173 00:07:12,450 --> 00:07:16,020 screen is off for example 174 00:07:16,020 --> 00:07:17,190 we are going to do it later, don' t worry 175 00:07:18,420 --> 00:07:19,910 for the moment just with 176 00:07:19,920 --> 00:07:22,376 the light on 177 00:07:22,376 --> 00:07:24,416 let's go to print "hello world" 178 00:07:24,416 --> 00:07:26,340 number one if you click start the 179 00:07:26,340 --> 00:07:27,030 simulation 180 00:07:28,110 --> 00:07:31,350 number one is 181 00:07:32,580 --> 00:07:34,410 there's a problem, it is repeating again 182 00:07:34,410 --> 00:07:35,760 and again and again "hello world" 183 00:07:35,760 --> 00:07:38,400 "hello world", hello world" 184 00:07:38,400 --> 00:07:39,919 how can we solve it? 185 00:07:39,910 --> 00:07:43,110 we can solve it for example using "borrar pantalla" 186 00:07:44,820 --> 00:07:46,530 but if we print and we erase 187 00:07:46,890 --> 00:07:48,240 there's no time to see anything so 188 00:07:48,240 --> 00:07:48,920 let's use a 189 00:07:49,530 --> 00:07:49,920 "esperar" 190 00:07:53,160 --> 00:07:56,130 so we will print "hello world" 191 00:07:56,250 --> 00:07:57,749 we will wait for one second and 192 00:07:57,749 --> 00:08:00,060 then the screen will be erased again 193 00:08:00,540 --> 00:08:01,800 and we need a second "esperar" 194 00:08:01,800 --> 00:08:03,780 because this way it will be 195 00:08:03,780 --> 00:08:06,000 a kind of blink okay can you 196 00:08:06,000 --> 00:08:08,820 imagine how will it work? "Hello World" 197 00:08:08,940 --> 00:08:10,860 for one second then nothing for one 198 00:08:10,860 --> 00:08:11,280 second 199 00:08:11,310 --> 00:08:11,910 then we start again 200 00:08:12,960 --> 00:08:14,430 Let's start the simulation 201 00:08:20,160 --> 00:08:22,440 Can you see? It's a kind of blinking 202 00:08:25,710 --> 00:08:28,950 This block, the first one, there's no 203 00:08:28,950 --> 00:08:31,170 need to be the forever block 204 00:08:31,170 --> 00:08:31,740 it can be here 205 00:08:33,063 --> 00:08:35,490 this way the screen will be switched 206 00:08:35,490 --> 00:08:37,289 on just once 207 00:08:38,490 --> 00:08:40,710 In this code okay so 208 00:08:40,710 --> 00:08:42,808 Let's start the simulation again and you will 209 00:08:42,808 --> 00:08:44,340 see that it works the same way 210 00:08:45,796 --> 00:08:46,440 Hello world 211 00:08:47,520 --> 00:08:47,910 nothing 212 00:08:52,590 --> 00:08:53,942 now I want you to see that 213 00:08:53,942 --> 00:08:57,222 switching the light on 214 00:08:57,240 --> 00:08:58,920 doesn't mean 215 00:08:58,920 --> 00:09:00,270 that this one will not work 216 00:09:04,910 --> 00:09:06,990 there is no light but we 217 00:09:06,990 --> 00:09:09,840 can see the code so 218 00:09:12,990 --> 00:09:15,840 okay but there are more instructions to 219 00:09:15,850 --> 00:09:17,970 take into account this one is really 220 00:09:17,970 --> 00:09:20,610 really interesting, it means 221 00:09:20,610 --> 00:09:23,070 "establecer posicion", position means where we 222 00:09:23,070 --> 00:09:24,210 want to 223 00:09:26,520 --> 00:09:28,080 to print the character for example 224 00:09:29,670 --> 00:09:31,681 imagine we want to print the character 225 00:09:31,681 --> 00:09:34,161 in position number 226 00:09:34,160 --> 00:09:36,240 well, first of all 227 00:09:36,240 --> 00:09:40,800 there are columns arrows every every every 228 00:09:41,010 --> 00:09:41,580 LCD 229 00:09:43,126 --> 00:09:46,805 I'll run the simulation, it will be easier with light 230 00:09:54,120 --> 00:09:57,420 there is a first row 231 00:09:59,180 --> 00:10:01,140 there's a second row 232 00:10:01,140 --> 00:10:04,440 and there are columns this is the 233 00:10:05,340 --> 00:10:07,890 room number zero this is raw number 234 00:10:07,890 --> 00:10:08,530 one 235 00:10:09,875 --> 00:10:12,185 this is column numbers zero, one, two, three 236 00:10:12,185 --> 00:10:17,375 four, until fifteen okay so with this 237 00:10:17,375 --> 00:10:19,805 block, "establecer posición" 238 00:10:19,925 --> 00:10:22,985 we can decide where we want to print 239 00:10:23,015 --> 00:10:26,015 for example imagine want to print in 240 00:10:26,555 --> 00:10:29,285 first raw, number zero, 241 00:10:30,185 --> 00:10:33,365 position the middle more or less number 242 00:10:33,455 --> 00:10:36,815 eight instead of typing "hello world" we will to 243 00:10:36,815 --> 00:10:37,685 type something like that 244 00:10:40,025 --> 00:10:40,985 let's have a look 245 00:10:45,935 --> 00:10:48,935 It is printed there in the middle of the position 246 00:10:49,955 --> 00:10:51,815 we can change position for example instead 247 00:10:51,815 --> 00:10:54,785 of number row I mean column eight 248 00:10:54,845 --> 00:10:57,275 we can chose column four 249 00:10:57,275 --> 00:10:59,735 and instead of using raw zero we can use row one 250 00:11:04,905 --> 00:11:08,225 Now the position is different 251 00:11:08,225 --> 00:11:09,965 raw number one, remember this one the upper one 252 00:11:10,205 --> 00:11:12,545 is zero and the other one is one 253 00:11:12,665 --> 00:11:14,915 position zero one two three and four 254 00:11:15,185 --> 00:11:17,555 so we can decide where we want 255 00:11:17,555 --> 00:11:20,255 to print things okay 256 00:11:25,745 --> 00:11:28,835 very very important defining the different addresses 257 00:11:28,835 --> 00:11:29,885 for everyone 258 00:11:33,995 --> 00:11:36,005 we can print in different LCD 259 00:11:36,005 --> 00:11:39,755 for example I'm going to duplicate this block 260 00:11:39,815 --> 00:11:40,535 on this part 261 00:11:44,060 --> 00:11:45,939 I want 262 00:11:45,965 --> 00:11:48,600 the program number two two and I'm going to 263 00:11:48,600 --> 00:11:52,205 program it in number twelve 264 00:11:53,315 --> 00:11:55,325 raw number zero 265 00:11:56,795 --> 00:11:58,985 i'm going to print it 266 00:11:58,985 --> 00:12:01,205 in number two instead of 267 00:12:01,205 --> 00:12:01,535 using 268 00:12:03,087 --> 00:12:06,365 this one. I'm going to use the slash 269 00:12:06,365 --> 00:12:09,785 I'm going to erase them too ok this way 270 00:12:09,785 --> 00:12:10,835 you can to see that we can 271 00:12:10,835 --> 00:12:13,625 program different screens at the same time 272 00:12:13,955 --> 00:12:15,965 because they have different addresses 273 00:12:15,965 --> 00:12:18,485 Let's have a look. So we will have two different 274 00:12:18,515 --> 00:12:20,525 blinkings one for the first one the 275 00:12:20,525 --> 00:12:22,085 first one for the upper 276 00:12:24,755 --> 00:12:29,825 here this character, here the second character 277 00:12:29,825 --> 00:12:30,815 I can also 278 00:12:31,955 --> 00:12:35,075 I can also switch the light on for the 279 00:12:35,075 --> 00:12:35,915 second one 280 00:12:37,595 --> 00:12:37,985 okay 281 00:12:39,155 --> 00:12:40,595 and let's start the program again 282 00:12:43,800 --> 00:12:46,400 easier to see if the light is on 283 00:12:47,105 --> 00:12:51,605 so we have these different instructions 284 00:12:51,695 --> 00:12:52,535 "configurar" 285 00:12:53,345 --> 00:12:57,665 to define the program, the language, the code we are going to use 286 00:12:57,680 --> 00:13:00,109 we are going to use this one, so don't change it 287 00:13:00,120 --> 00:13:03,360 and the addresses we are going to use 288 00:13:03,360 --> 00:13:06,120 every screen will have a different address 289 00:13:07,400 --> 00:13:11,280 we also have this block, the LCD "activar luz de fondo" 290 00:13:12,485 --> 00:13:13,055 we can 291 00:13:14,465 --> 00:13:16,655 erase the screen there are other possibilities 292 00:13:16,655 --> 00:13:17,705 but from the moment we are going 293 00:13:17,705 --> 00:13:21,098 to use just this one "activar luz de fondo" 294 00:13:21,245 --> 00:13:24,005 or switch it on and switch it off 295 00:13:24,335 --> 00:13:26,555 or "borrar la pantalla", erase the screen 296 00:13:26,975 --> 00:13:30,245 we also have "establecer 297 00:13:30,245 --> 00:13:33,095 posición" means define where you want to 298 00:13:33,095 --> 00:13:33,455 print 299 00:13:33,905 --> 00:13:36,005 to define the position you want to print okay 300 00:13:36,665 --> 00:13:38,675 and here "imprimir" means you are going to 301 00:13:38,675 --> 00:13:41,859 write something on this position 302 00:13:41,859 --> 00:13:44,375 the one you have already defined really 303 00:13:44,375 --> 00:13:47,585 really easy using these screens connecting them 304 00:13:47,591 --> 00:13:49,685 and you only have three or four 305 00:13:49,745 --> 00:13:52,127 types of blocks okay four types 306 00:13:52,127 --> 00:13:53,887 of blocks, nothing more than that 307 00:13:53,885 --> 00:13:55,895 okay so the exercise for you is 308 00:13:55,979 --> 00:13:58,475 is not going to be difficult, you will have to 309 00:13:58,475 --> 00:13:58,895 repeat 310 00:14:00,185 --> 00:14:04,415 again we will have two screens 311 00:14:05,255 --> 00:14:06,275 start simulation 312 00:14:07,535 --> 00:14:09,415 and they will behave this way 313 00:14:10,085 --> 00:14:10,445 okay 314 00:14:12,965 --> 00:14:13,415 so 315 00:14:14,705 --> 00:14:17,105 it's not difficult just kind of blinking 316 00:14:17,165 --> 00:14:19,645 but with different positions, first position 317 00:14:19,635 --> 00:14:22,595 second position, third position, fourth position 318 00:14:22,985 --> 00:14:25,175 the first two positions in 319 00:14:25,175 --> 00:14:28,895 the upper LCD screen and the two 320 00:14:28,895 --> 00:14:32,375 following positions in the lower LCD screen 321 00:14:32,375 --> 00:14:34,595 okay if you have understood 322 00:14:34,595 --> 00:14:39,335 the example. Programming it it's really easy 323 00:14:39,605 --> 00:14:41,885 so that's all 324 00:14:43,445 --> 00:14:44,825 all you need to know