1 00:00:00,000 --> 00:00:04,440 Hello! In this video tutorial, in this exercise, we are going to learn how to 2 00:00:04,440 --> 00:00:11,000 use a... how to control a temperature pressure, temperature sensor, I'm sorry, 3 00:00:11,000 --> 00:00:17,339 with the Arduino board, ok? And the first thing we need is a temperature sensor 4 00:00:17,339 --> 00:00:23,120 and you will find it in the library, the basic library, where is it? Here, 5 00:00:23,120 --> 00:00:31,399 temperature. So just click and drag, put it on the protoboard. This sensor temperature 6 00:00:31,399 --> 00:00:39,479 has three connectors. The first one has to be connected to 5 volts, the third one is 7 00:00:39,479 --> 00:00:43,979 connected to ground using the black wire and to the ground connector of the Arduino board, 8 00:00:43,979 --> 00:00:48,979 and the third one, the one in the middle, is the one that is going to be connected to 9 00:00:48,979 --> 00:00:57,100 analog input, A0 for instance, and this is the one that is going to read the voltage from the sensor and the Arduino board will 10 00:00:57,859 --> 00:01:03,740 will know the temperature, will read the temperature using this this wire and this voltage, okay? 11 00:01:03,740 --> 00:01:06,280 So the connection is really really easy as you can see. 12 00:01:07,040 --> 00:01:09,439 How can we program it? It's really easy too. 13 00:01:10,099 --> 00:01:15,319 Forget about the second block. The important thing here is the purple one. The purple one is an input, 14 00:01:15,319 --> 00:01:21,079 It is a specific input for a temperature sensor. 15 00:01:21,079 --> 00:01:25,120 And the thing we do is leer el sensor de temperatura en el pasador A0. 16 00:01:25,120 --> 00:01:27,239 It means we read from this connector. 17 00:01:27,239 --> 00:01:31,200 We can read from A1, A2, A3, A4 or A5. 18 00:01:31,200 --> 00:01:34,560 We are going to choose A0 just because we want. 19 00:01:34,560 --> 00:01:40,159 And this is the unit we want to use, degrees, Celsius degrees. 20 00:01:40,159 --> 00:01:48,480 So the moment we have this block, we can store the reading in a variable called temperature, 21 00:01:48,480 --> 00:01:55,640 and then we can send it to the monitor series, serial monitor, I'm sorry, using the block 22 00:01:55,640 --> 00:01:59,540 we have already used in several exercises, okay? 23 00:01:59,540 --> 00:02:02,379 Really really easy the connection, really really easy the programming. 24 00:02:02,379 --> 00:02:05,700 Let's have a look at the simulation. 25 00:02:05,700 --> 00:02:12,800 If I start the simulation, nothing happens apparently, but the reading is here in the 26 00:02:12,800 --> 00:02:14,000 serial monitor. 27 00:02:14,000 --> 00:02:20,460 Now this sensor is reading 24 degrees. 28 00:02:20,460 --> 00:02:21,460 Why? 29 00:02:21,460 --> 00:02:28,620 Because if we click on it here, on this bar, we can decide what's the temperature outside, 30 00:02:28,620 --> 00:02:31,319 or what the temperature is outside. 31 00:02:31,319 --> 00:02:39,879 And 49 here means that the Arduino board will read 49, 76 or 78, it means that the Arduino 32 00:02:39,879 --> 00:02:42,500 board will read 78, ok? 33 00:02:42,500 --> 00:02:45,960 So the simulation works. 34 00:02:45,960 --> 00:02:52,379 Your exercise will be a little bit more complicated, but just a little bit. 35 00:02:52,379 --> 00:02:59,680 I'm going to show you the program in real life, as usual, as always, I have my Arduino 36 00:02:59,680 --> 00:03:05,180 over here and I have a sensor here. You can't see it because it's small but 37 00:03:05,180 --> 00:03:12,080 believe me it's here. And we are reading it. You can see the measure in the 38 00:03:12,080 --> 00:03:19,620 serial monitor. Now in this room there are 22 degrees, okay? If I touch it 39 00:03:19,620 --> 00:03:27,699 temperature will rise. It makes sense. 23, 24, okay. It works. My device is working. 40 00:03:27,699 --> 00:03:36,439 I have had to make a modification because this reading is different. 41 00:03:36,439 --> 00:03:43,939 If we have a look at the text taken from the computer, this line is different. 42 00:03:43,939 --> 00:03:44,939 Can you see? 43 00:03:44,939 --> 00:03:51,280 Temperatura equals minus 40 plus number multiplied by analog read minus 20. 44 00:03:51,280 --> 00:03:57,080 This line is not the same than this one. 45 00:03:57,080 --> 00:04:02,659 This is because I have a different temperature sensor, but it's not a big problem because 46 00:04:02,659 --> 00:04:12,120 if you look for information, for instance here, the sensor I'm using is the LM35-1. 47 00:04:12,120 --> 00:04:18,160 If I look for information, I will find how to connect it and I will find how to read 48 00:04:18,160 --> 00:04:24,199 it using the Arduino board, okay? 49 00:04:24,199 --> 00:04:27,720 So this is the only line I have modified. 50 00:04:27,720 --> 00:04:36,040 another modification too, because I have added something to control a buzzer. 51 00:04:36,040 --> 00:04:42,639 The buzzer is here. The buzzer, the speaker, it makes sounds, it makes sound. 52 00:04:42,639 --> 00:04:46,500 You already know how to program it and if you don't remember, go back to the 53 00:04:46,500 --> 00:04:54,000 exercise when we use it, okay? It's really easy to do. We have a specific 54 00:04:54,000 --> 00:05:01,180 output, I want to remind you, here there is a specific output in the library, let's 55 00:05:01,180 --> 00:05:06,040 go back to the library, Salida, we have a block here, Reproducer Altavoz, okay? 56 00:05:06,040 --> 00:05:12,000 Using this one and a weight you can control the the buzzer, okay? So let's go 57 00:05:12,000 --> 00:05:17,199 back to my circuit, the real one, so I have the Arduino board here, the big 58 00:05:17,199 --> 00:05:24,399 I have my buzzer and I have my temperature here, my temperature sensor, 59 00:05:24,399 --> 00:05:31,420 okay? And let's have a look how my sensor works. Now we are reading 22. If I touch 60 00:05:31,420 --> 00:05:35,259 it, temperature will rise. And I have programmed the circuit that if 61 00:05:35,259 --> 00:05:40,180 temperature is higher than 25, the buzzer, this one, will produce sound. Let's have 62 00:05:40,180 --> 00:06:03,860 I touch it. 22, 23, 24, 25, 26. Can you hear it? So my circuit is working. If I remove my hand from the device, the moment the temperature becomes lower, it doesn't sound anymore. 63 00:06:03,860 --> 00:06:07,759 So this is the exercise you have to program using the simulator. 64 00:06:07,959 --> 00:06:08,699 The simulator, yes. 65 00:06:08,959 --> 00:06:09,600 It's really easy. 66 00:06:09,899 --> 00:06:12,160 You only need to click and drag. 67 00:06:14,120 --> 00:06:16,199 You need to click and drag the buzzer. 68 00:06:16,420 --> 00:06:19,540 You need to connect it to ground and to one of the digital devices. 69 00:06:20,060 --> 00:06:22,839 And using this block, the reproducer altavoz, 70 00:06:23,279 --> 00:06:26,740 and the block that is the weight, okay, remember, 71 00:06:27,500 --> 00:06:29,839 and adding them here. 72 00:06:29,839 --> 00:06:33,939 And you will also need the condition, the if block. 73 00:06:34,060 --> 00:06:34,899 You remember the if block? 74 00:06:35,180 --> 00:06:36,339 Be if and a temperature. 75 00:06:36,740 --> 00:06:42,939 So if something happens, then if temperature is higher than 25, for instance, or 50, whatever, 76 00:06:43,620 --> 00:06:49,160 then the buzzer will produce sound, okay? 77 00:06:49,319 --> 00:06:50,420 I think it's really, really easy. 78 00:06:50,540 --> 00:06:51,519 You know all the blocks. 79 00:06:51,720 --> 00:06:53,839 You already know all the blocks you need, okay? 80 00:06:53,839 --> 00:06:59,819 And your simulation will work the same way my real circuit has worked, okay? 81 00:06:59,839 --> 00:07:04,259 So think about it, it's not complicated, and good luck.