Arduino: Beginner to Pro (Huge Class) | Alexey Naturyev | Skillshare

Arduino: Beginner to Pro (Huge Class)

Alexey Naturyev, Programmer and Designer

Play Speed
  • 0.5x
  • 1x (Normal)
  • 1.25x
  • 1.5x
  • 2x
37 Lessons (6h 41m)
    • 1. Overview

      2:10
    • 2. Introduction

      2:10
    • 3. Software Introduction

      6:40
    • 4. connecting a LED

      3:02
    • 5. programming a LED

      4:19
    • 6. control the LED with a button

      12:26
    • 7. boolean function

      11:37
    • 8. RGB LED introduction

      10:06
    • 9. RGB LED with buttons

      16:44
    • 10. Potentiometer Circuit

      19:41
    • 11. Potentiometer

      12:40
    • 12. dim a led with the Potentiometer

      11:33
    • 13. Servo Motor introduction

      10:59
    • 14. Control the servo motor with a potentiometer

      11:45
    • 15. Joystick Circuit

      6:14
    • 16. connecting and programming the Joystick

      17:15
    • 17. Control the servo motor with a Joystick

      11:47
    • 18. Detect Position understanding

      4:18
    • 19. Tilt Switch programming

      13:59
    • 20. Sound Sensor with an Led

      17:53
    • 21. Sound Sensor with a Matrix

      14:18
    • 22. what are LDRs?

      0:10
    • 23. understanding the LDR

      22:52
    • 24. programming the LDR

      9:24
    • 25. Project: LDR combined with LED

      10:25
    • 26. KeyPad

      17:48
    • 27. Keypad with a LCD Display

      15:40
    • 28. Project: clapping Fan; connecting

      9:02
    • 29. Project: clapping Fan; programming

      10:33
    • 30. decode the controller

      18:40
    • 31. control a LED with the Infrared Sensor

      12:26
    • 32. introduction to Ultrasonic

      0:07
    • 33. connecting the Ultrasonic Sensor

      4:56
    • 34. understanding what to program

      3:39
    • 35. programming the Ultrasonic Sensor

      15:22
    • 36. converting cm/microsecond to km/h

      7:30
    • 37. measuring distance with the Ultrasonic Sensor

      21:14
12 students are watching this class

About This Class

This Class is all about the Arduino Microcontroller and the modules that you can use with the arduino (motors, etc.). This Class is a great opportunity to learn Arduino through projects. You will be able to start making projects right after the introduction. I will always give you the code that I have programmed for the projects in this course, but I would like to challange you to program it yourself to make sure you learn as much as possible.

Transcripts

1. Overview: hello and welcome. Because of Martina. I think the best way of earning arena is with projects, and that's what this course is all about. Off course, we will need some physics and even a little chemistry to explain how sensors work. But that's just a small part of this course and following I'll show you some projects that we learned in this course with a potential meter. Everything works. Now. If we press see, everything is being deleted. Now, before I turn this light off, you can see that the led goes on. But I go on. If that sounds good to you, stay excited, and I hope we'll see you in this course. 2. Introduction: hello and welcome. Because of Martina. I think the best way of earning arena is with projects, and that's what this course is all about. Off course, we will need some physics and even a little chemistry to explain how sensors work. But that's just a small part of this course and following I'll show you some projects that we learned in this course with a potential meter. Everything works. Now. If we press see, everything is being deleted. Now, before I turn this light off, you can see that the led goes on. But I go on. If that sounds good to you, stay excited, and I hope we'll see you in this course. 3. Software Introduction: Hello and welcome back to the course of party. Today we will learn what the RV No integrated development environment is which is the software for our, you know, and how to use it. So let's start up here. We have the tool section. Um, that's the section where we go to connect or computer to the arena. So there we have the different ports. It will show if we have the arena connected, it will show on one of these courts the name off the artery. No, Andi. Then we have to select two. Yeah, we have to select or check if they are. We know that we connected to the computer. It's the right board, which you can see here. So if you have the Marine Omega, which is here, you would click on Guardian Omega. And now you would have the right settings to upload your programming code to 30. You know, um, that's the coach. That's the section where we program. So we have the white set up, which will run only once on, and we have the white loop which will repeat all every time. So, um, if you write double slash like that, the program doesn't use your code, that's what just the comments section. So that's what we're standing here. Is that this No code. So I can just delete that we don't really need that another important thing way. Have the serial morning er which is here. You also confined it under tools serum, Cereal monitor. Yeah, we cannot open it right now because we don't have been already know connected, but he would find it under under the tool section. Or you can just click on that sign here. Also very important. Our libraries. They just provide more functionalities. If you let's say, if you have a mortar, a serval mortar, it's a mortar, you can you can decide how far to turn with the degrees. We will learn that in this course. If you have that mortar, we would need include a library. You can do that under sketch include library. And here we have all the different libraries can click on them life like that and then it will ride the coach that we would. We can also also right that so you could just right um hashtag include serval h. And that's just the same as we include our library through the sketch section. If you want to save your coach, which is always good programs that if you programming something, you should always save it to make sure you don't lose it. She was just going to save us. And then you can go to your documents or whatever you wherever you want to save it. I'm not going to say that coat because we obviously have. Did program get anything? So if you have your downward, your libraries under under oh, under file can find examples. So if you don't Lord download some libraries, they usually have some examples. That's just a sample code, how to run the module or something. So if we go on stepper working up will open and youth, um, top with the with the code for that model. I don't need that right now. So, um, also, you can if you, if you did any mistake or something, you could press Redux, which is controlling Is that so that it will re do the thing that you just did or undo? Uh um, the software is pretty amazing because if you did any mistake and to try to upload your coach to already know before it uploaded the code and will show you the mistake you did if you forgot something in the code. If you're goto, if you have to write something with a capital letter and you forgot that it will stop it and show you that you did something wrong and then you have check out, check your coat. So here you can verify and control your code. If you did any mistakes, we don't have any code right now. Except that thing up here so we won't have any problems. Um, I think we're pretty good right now. Um, yeah. So the serial monitor is just a connection between the Arduino on the computer. That means if you send if you want to control something, if you want to check a state like from button or potential emitter, we later learn that later on. But if you want to check a state, it will show it right in the cereal monitor that you can check the stage on program further if you want you to upload your code to the Ari. No, He would go to that upload button, which is their arrow arrow on the left top corner on. I think we're pretty good. So I hope I hope the army, you know, environment is not too difficult to understand on see in the next video. 4. connecting a LED: in this year, I'll show you how to control analogy with an arena. So let's get started. So what we will need for this is a brand board are you know, doesn't matter which type two wires. I just chose a red 14 plus in a black one for minus are led off course and a resistor. We need 100 k resistor. The number is usually on the resistors band thing here. So the led that long thing it's plus and the short thing is minus. So plug in the led to a bad board and one and one end off the resistor we will pluck into the line off one lag off the led Doesn't matter which one should look like that. Then we use the wire. If we plug in a wire, it will affect a whole row. So if we if we plug in the wire an example here, it will affect all all the all the all this road so all the sorrow will be minus. Now we plug plug in the plus cable in here which you go which have been a row with a longer lag off the led plug it in And then we pluck the black wire to ground on the arena, which is minus, and the red one connect their to five walls, just plus no, we have everything connected and just block the Campbell into your computer. Andi, the led should go on. Don't worry. If you didn't get it with that picture, you should be easily able to get it on. We didn't program it yet. So in the next video, we'll learn how to program, how to turn on that lady and turn off the led. So see in the next video. 5. programming a LED: Hello and welcome back to the course of Martina. Today I'm gonna show you how to control Led with Arlena. So let's get started. Okay? So basically, you will use the same stuff that we pulled last in the last video grabs. We will take the five bold wire and put it into digital pin eight. All right, now we're ready to program it. No, to the programming part. So we have buoyed. Set up. Um, that will only your on once. Yeah. We just set up our coat there. And the void loop. That's where were you? Bright, though. Main program. It will repeat over and over again on yeah, that's where the main program is. So are led is in a digital pin. Eight. So we write pin mode. AIDS output, we declare. Been more Raiders output on, say, digital rides eights. Hi. So, in the made coat, it says that's our led or the pin. The pin digital pin h will be high, so I really should go on. The first thing that we have to do is to go to tools, select or board, which is the order, you know, you know, or which port you're using on and we have to select the port, which is, um, yeah, we'll show you are already knew there, and then you just click on it and that's it. Then we upload it 30. You know, you could say that if you want. I won't do that because pretty simple code. Um, we'll take some time and what's it's uploaded. It should. The led should go on. So you sick? Looks like that. So the led his own? Um, no. Let's say you want led to turn off. We say DeLay 1000 milliseconds. That means one second we will stay one second on. Then we say digital riots, right? Only goodness, digital rides, aids. Hello. That means it will be on for one second, and then it will go off. And let's say it should stay off for one second so it will blink That will be on for one second. Then it will turn off for him for one second, then will repeat infinity times. Let's upload that and see what happens. Once it is up a little show you again. Here it's blinking. Yeah, that's a problem Video. In the next video, I'll show you how to control the led lamp with a button, so let's see the next video 6. control the LED with a button: today, I'll show you how to control. Led with a button. So let's get started. So we will need in order, you know, a few wires and, um course a button. Um, I'm led and a resistor. There we go on a brat board, Of course. So firstly, blood in the led. Remember the long Legace Plus in the short ones? Myers, I'm getting like that. Then we need or resistor to make sure we won't. Damage are led. The resistor should be around 220 homes, so Oh, it's pretty hard to play in the sister. There we go. Okay, then when you're positive here. So if we put ground in here and this, I think the whole arrow will be minus. If we plug five volts in here, the whole role will be five holds. So got it when I do that ground here Short lank. So this will be minus. You can just plugged into that role. Well, we'll actually use the smaller wire like that. That's, uh I love this into ground. This one into a digital pin cost. Well, reads the state off the button. Let's just say the open seven on the led off course, we'll pluck that into so little pin 10 but you declined, and now we're ready to program it. I will show you, as usual in normal, more detailed picture so you can follow that. And if you wonder how the button works, don't worry. So, um, you see these four legs? If you press the button, the, um, the two to Lexa will connect, like if you if you haven't like that plucked into your, um, Brad board, these two legs will connect, and, um, the arena will see that on change the state off the bottom. So if the button was one, if the button said was one and we pressed the button, the broken state will be zero. Okay, So if you want to, you can pause the video and check out that picture off the whole circuit. Okay. We have over, um, allergy at pin 10. So ripe in mod 10 output. Onda, we have our button at pin seven. So pin mode seven. It's input input. Pull up. Um, input only because we want Teoh. Have the state off the button on pull up because pull up will activate the resisters inside authority. You know. So the state that we will get from the button will beam or reliable. And no, too, though to the main part of the code, we need a manager, which is sent So, um into his digital digital breed. Seven, which is all our, which is our bottom pin on the inner drew we can call, Button said. So the buttons stage. It's the stage off the button. It's pretty simple. So, um, now we want to make a connection between the computer and the other, you know, which is called Serial Connection Here. So right Serial Begin 9600 which is only the rage off the serial come communication. Um, now we say serial what cereal Prince line, but instead so I already know will always send the state off a button to the computer, and we will see that on the screen. So let's upload the code. Let's check it already knows, connected. It is no uploaded on. There we go. You can find the serial monitor and under tools here, Or just click the sign on the top right hand corner so it will show one, and if you press the button, it will show zero. There we get. Show you that here pressed the button. Andan switches to zero. No, we want to do that with led. If we press the button that you should go on. So, um, r l e d s a pincer 10. So if if button stage is one nervous if button status zero we have to do that because of re write. Only one equal to it will think that it will change button state to zero. So we just want to check if Button said a zero. So we have to write. Two is equal to So if button ST zero digital rise the pin off the led Which ISP in 10 in 10 high. And now if the button it's pressed, that means the button will switch to zero. Power allergy will go on. And if our button is not pressed else else digital rights, the pin off the button again, love. So if if we press the button, the state will switch to zero. And if the state zero, the led will go on well, the allergy will go on. And if the state is not zero, that means the state will be one if the status one, um, which means that the bottom is not pressed the eligible remain low. So it's check the code. You can just check it with a button on the left. Um, had corner. It will show you if you did any mistakes in the code. Obviously not. So we will upload the code. So they are, you know, on There we go. If we press the button, our the led will go on. And the serial mourner will Oh, it's here will show zero. And the bustle led will go show you here if we press the button, uh, the lady will go on as soon as we release the button. The led goes off. So, um, that's it for the video. In the next video, we'll learn how to, um, press the button and the allergy will go on. And who pressed the button again? The allergy will go off. So yeah, it's even next video 7. boolean function : Hello and welcome back to the course of already. You know, in this video we will learn what Boolean function ISS and how to control the led with a button. So we have to press only ones on the island. You will start still will stay on until we present. Until we pressed the button again on the led should go off then. So we need three imagers, which are variables, um, one manager for the button previous state. So let's call it button previous one engine manager for the button current state on another manager for the budget current state. So let's call that one button state. Okay, so we have our, um doesn't pin at Penn seven. So we you want to, you read state off the off the pin off the button. So seven inputs pull up. Uh, on the easy, we declare a spin mode or put, which is on pin 10 and more. 10. Oh, it's put okay. Now to our Boolean function, bullion is just a variable which can have two values either true or false, so that it has only can be only these two values to our false and a 1,000,000,000 function is a function that returns true or false because it's a 1,000,000,000 function. So let's call the bullion function. Um, Button, make sure that you have these brackets here. Don't forget them. And we have to write that function outside the boy Luke, because the white loop, it's just a loop. And then we will right the function into that loop. But the probe but function we should right outside that loop. Okay, so we have the current stage. All the state are low right now because we didn't press the button. So the button states cannot be high. So let's say low lo on a low. Okay? So if the but in current is Hi Andi, the button previous is below. If that's the case, we will switch the, um he will switch the the led, So if it's on, we will turn it off. And if it's off, we'll turn it on. Okay, so we have again. We have to equal to year because you want to check the value off the variable. If it's high on and if we would have only one equal Teoh, that would change the value. So to equal who is just to check the value and one is to change the value. Okay, So if if we need, we need the bus and current, which should reach the, um, the button state. So but current is digital. Reach the button state, which is up in 10. Open seven. I'm sorry. Okay. No, the bus and current. This is the state that we press the button. Okay. Okay. On. And if the button current is high at the button Previous a slow if the button stayed. Remember the button status. The third manager we declared up there. If if that IHS um hi. If button stage is high brackets, if the button stages high, we will, um, switched the button. State too low is below, then well, else else the buzz and state will be low. If if that's not, If the button state is not high, the button said will be low. So else the brackets else button stage is Hi. So if if the button status high, we will switch it too low. And if it this below, we will switch it too high. And no, because it is a function. We need a return value. So return Bob Button State same here but state. Okay, so we have our condition up here. If that condition is true, it will go to the following part. And if if this is true, it will execute that part. Well, it will check another another state off the button if the button is high or not. Um, which is called conditional execution. And that if inside another, if we have, we have that if here, that conditional execution on then. So we checked a state here. Well, we checked two states, but yeah, um, if if if that thing is true, it will go to that. And if that is false, it will go to that. And, um yeah, but say so that if inside of if it's called mastiff because it's inside, so it is nested on. Well, now, let's go to the void loop. Let's use our button or busting function. So now we have our busting function here, and then we actually turned on the led digital, right? The allergy is a pin 10. So 10 um, button stage. And now we need to change the button. Previous two button current. We need to do that because we want the led to switch to off what was on. We want to switch it to all. And if it was off, we need to switch it to on. So we need the store, the the bus and current into that. But in previous. Okay, let's check the coach. We did any mistakes. No, we didn't. So we can upload. The coach should already know, You know, it's connected. All right. I'm gonna show you that. Yeah. There we go. So we have that Boston here. If we press it, the led goes on on. It stays on until we press it again. It will change button previous to but and current. And then we can control the button with control that led with the button. All right. I hope that makes sense that you understand it. See in the next video. 8. RGB LED introduction : this video, we will learn how to use RGB Led s on how to program them. Let's get started. We will need a resistor. Um, are you know Ah, bread bird four wires. Um and our RGB led. So the RGB led This one is Ah, come on catheter, Which means that it has one minus leg, so basically has three colors red, green and blue on. Um, it's just on led with all the three led is inside. So that's why we have three off thes plus legs and one minus leg. So this common Maya's leg issues for all l ladies so black in the her GP led. You can ban thes legs that smell problem, then the longer leg, it's usually the minus leg. So if it is a, um, common catheter RGB led the long neck is the minus leg. And if it's a common honored RGB led the long legs plus, so you would need for the smaller makes, we would need minus. So the longer the longer legs connected to minus sorry, you know, which is G nd on and the longer legs I mean, the plus legs will connect to digital pens. B W M Because we want to dim the RGB led. It's just Ah, you can do all all colors with a RGB led If you if you're dim or if he makes the colors, you can create a bunch of colors. So so this one should be a red. Let's use a red cable for that ranch. Let's put it to a digital pin nine. Then we have green. I don't have a green cable, so we'll just use yellow. So we have green here. Let's use pin 10 comes the blue one. Let's use pin 11. All right, I forgot. We need to use our resistor to make sure we won't damage the RGB led. So we put our resistor into the minus leg to the row of minus leg and to the minus row right here. All right, we have to connect the minus row to the already. You know, GNB now we have or circuit for their RGB led. So let's program it. All right, we'll create three energy dispersed that will make our lives easier. So, um, we have entered your head switches on pin 10 9 Then we have green, which is pin 10 or and, um, balloon. We're just pin 11. Okay, so we declare all these pins as Harper because you want to use them as output. So pin mode. Read our food. Red is nine. So nine is output. Then we have been much green are put on spin mode. Blue output. Okay. No, we want to, um, dim the led the different ladies as example. Dim red. So right. Analog arrives. I don't Look, we're right, Brad. And now we can choose a number between zero on 255 so see, roast minimum and 255 s maximum for the brightness off the L A. D. So it's just say 255. Okay, Now, if we upload the code, that's what Check our you know. Yes. All right. If we upload our corn code now, the allergy should turn red. So upload the code way. Go. That lady is right. Okay. No, let's try and makes the different allergies. So we get a new color. That's a analog, right? Let's still lead. Right on. Let's rise. I like, right, Let's Let's mix green and blue. Green, green. Let's say 15. 15 on. Let's there blue 100 I believe. 100. Okay, let's check. Or coach, We have any mistakes? Probably not. You can upload the code on. There we go. Can see it looks pretty blue. I'm just gonna change. Um, blue, too. 10. Upload that, Uh, see, if we make any mistakes, the program will tell us before it uploads the coach. If there's any mistake on there we go. No, it's ah more green than blue. If we put both 50 there we go. Okay, So that's it for this video. Now you should know how to control the led RGB led on. And, um, in the next video, we'll learn how to control the RGB. Led with multiple buttons. So you press a button a surgeon color should go on and that stuff. So see in the next video 9. RGB LED with buttons : in this video, we will learn how to control the RGB led with three buttons. So let's get started. All right, so let's take a previous circuit with our Torino on the RGB led on. Let's at three buttons later. We want to control the RGB led each color with one button. So it's placed the three. Butters, they're a week, uh, like that and we have the minus row here. So we place the minus, um, off the button. We place the Myers off the bus into the narrow, each buttoned. There we go. Cables. I'm a little longer once. Now we can is the cables on and put them into the pins off already. Know, let's put them in 23 and four to to three. And for Okay, Okay. No, we have all the three buttons connected. The first button, too. To the digital pin to York, the arena, The second button to the digital pin. Three or three off the are, you know, 1/3 button to the digital pin for off the arlena. Now we're ready to program it. I'll show you, of course, in the more detailed picture right now and then we can start programming. So all right. So you could use the code that we had in the previous video. But I would recommend you to write a new one because you will learn the come other instructions on the finds is much better if you write the code over and over again. So let's write it. Let's run. Um, so we had three imagers. One for for nine in in a jerk or read off the RGB led the red leg is, um it's on pin nine. So And bread is nine. That we have in Marine is 10. And and blue is 11. Okay, now we have to declare their mall s output. So you say pin modes, pin modes red. I'll put then green our perch on thin mode, I believe are good. Nice. So now we have three buttons for each off the, um l ladies. So the first button is that him to? So we had that in our l E G control video. You remember pin modes have been off the button, which is thing two. And now input pull up because we want to read the stage off the button. We have to do that with each button. So with button on pin for well on and the third button, which is underpinned for swell. Well, okay, so now we declared the led pins as output and the button pence's input pull up. Because of the sisters inside Laurino, they will make the on stage that we will get back from the arena more reliable. So now we want to you read the actual state of the buttons who rise? Um, state no se, but one state Sorry and no, but one stage is digital read pin, too. Our first button we have a button to state is digital raids the bottom on pin three. So three blood and three stage is digital reach. Um, but in the third button, which is on pain for so no, we have no. We read all the states off each button. Andi, no. If the button, that's if but one if buts And one state is we have to remember we have Teoh right to equal to, because it's a relation on. We want to see if the button one the state of button one is equal to something. So we need to right to equal to If he would write only one. It would say that it would put, but in one state and the thing that we were right after the equal to thing. So we have to right to go to make sure you do that. So you if the button one status zero, that means that the bottom first button was pressed. We say on a log. Right? Um, read. Hi. So if we press the button, the first button, um, the decimal number were Walter into zero from 120 Hopefully on them are the RGB led The red part should turn on. So sorry we just write 255 because it's an elect. We have a state between low and high, not only low and high. That's what analog is. So let's let's let's try that and uploaded block. Org nine. Nice. No already connected. Well, we check in on, and but in one state was not declared in this scope. Oh, I'm sorry we have to ride in manager again, so that's pretty useful on the check function. If you have any mistake, if you made any mistake in your code, it will show it before you cannot close your coat. So let's check it again. No, everything is right. So it's uploaded. Nice. If we press the button, the elegy RGB led will turn right now. Um, so let's continue else else if the button the button to state, um is zero if the button to so if a budget to state. So if the button the second button is pressed same concept us with first button, I could press it will turn to zero on tickets zero. We want Teoh. We want the rgb led to turn off the the red on turn on the, um turn on the green one So say and, uh, rights green 255 on copy down, Brad zero. And we want the blue 120 a swell if the blue one is on who want to turn off the blue on And here we want to turn off the and it the the blue one at the green one. So if the first button is pressed, it will turn off the blue light and the green light and only the red light wall Turn on. And if the second button is pressed, it will turn on the green light on Turn off both the red and the blue light. Now we have 1/3 button else. If bots and third States is zero can just copy that. So if the Boston butts and three it was pressed, then you want to turn on the blue light, turn off every other light. All right, so let's check if we met any mistake? No. Now we can upload it to the arena. Let's do that. There we go. I'm going to show you, uh, here. If we press this button well, the red one will go on to repress this one. The green one will go on. And if we pressed, the last one blew. Should go on. There were less. So that's it for this video. Um, I hope I hope you will get that looks kind of messy, but I'll show you the picked, the more detailed picture. So don't worry about that. I see in the next video 10. Potentiometer Circuit: Hello. Everyone in this lecture river learned about views in Teradata SQL and we will also see the advantages off using views. So views in a stool and nothing but a saved escalate quickly revert. Normally complex are big school queries. Results are stored using views. So let's see an example in which we're going toe preparing a skill query and we're going toe stored. The result off school, Grady using views select static from die start imply this is my first table. So I'm going to use joints toe. Combine this table with another table, which is called department table select. So this is my department table in this table. I have this department I d through this department idea. I'm going to join this imply table, you know, join department. He be on condition Igor department I d equals to be dark department. I d. So let me quit this imply name. He don't imply name. E dark position, A dark facility. Be dark Department name for this is my SQL query. Let me executor discreetly. So the result off this escort, Grady, is not saved anywhere. So you think view, I can save the result off this Siskel quickie. So let's create of you create view then the name off you, Let's say employ underscore view. So this is my name. Name of you? Yes. This select execute disk Ready, Create view completed. So in order to retrieve the data from view, I will use select statement Select static from name off. You bitches imply underscore view. Look, data has been saved in this imply underscore view. So any time, if I'm required the information off this SQL Grady instead off running dish skulking Quaid e with joints. I will just execute this view, which is imply underscore view, you think Select statement. So in this Lee, I can avoid complex joins, aggregate functions and many other things. So let's say I don't want the salary column in my view. So in order to modify the result off view, I will use replace view statement. So lets you here in this result, I don't want this salary column, so I will just write, replace view, remove the salary column and from this Grady. So let's execute this replace you completed. So let me execute this escalate e look. Ah half modified this view using replace you statement the lecture. I don't find this view anymore. So I've used drop view statement to drop this year. So drop view, then the name off, you imply underscore view is my name. So let me execute this. Drove you completed de imply underscore view, local imply and a Scorpio doesn't exist So this has been dropped. So what are the advantages off using view? So these are the advantages. So user can be given access only to views instead off base tables. So instead of giving access to these imply in department tables, I can create a view and can only give access toe this particular table imply underscore view. So this is the benefit off using view. You can save the desire a school query result using views and later can be used if it requires. So so, these are some benefits off creating of youth 11. Potentiometer: All right. So let's connect our potential ometer to our arena. Let's take our bread board the potential meter. Um, yeah, just dig in the If you have the L ago potential meter, he need to first put in the, um, plug in the, um, the stick to the actual potential ometer, and then you presently larder. It will go in, just press a little, and then what? You're kind? Well, hopes. Make sure that you don't do it that way, because remember, if you plug it in that way like that, and then you connect the ground here and the 55 volts here, you already know will die because, um, you remember that they're all on Lee effects the whole row. So, um, you have to plug in your potentially ometer like that to make sure you're I'm ground and your five volts are not connected. So make sure that, um, plug it in like that and not like that. So it's still like that. Okay. Oh, that's pretty hard to connect it. Think I ben thes legs a little? Okay, there we go. So we have to know we have the 10 geometry connected that's plugging the wires. I will use a red wire for five goals. Remember the whole row? Um, if you plug in the wider the whole rose affected. So we'll use the black wire foreground, which is Cyril's. Remember, the third leg from the physical circuit video. You have to connect the third leg as well. So the five ball play goes into the five boards off the order, you know? Okay, that rules. And the ground goes to the ground authority, and I then and now we have the third leg. Um, which is the voltage output? We will. That's how we measure the, um, the state off, the potential meter, how far we turn the potential meter stick thing. So let's plug in that into, um, let's say and looked in one because they want to read that. No, it looks like that. The whole thing and this one looks take down. Okay. All right. So let's switch to the programming part. All right, So the program is actually pretty simple, So we needs the value that we get from, um, from the order, you know, which will know whether our arena will receive the value off the voltage. The potential meter, which we saw in the physical circuit video. So let's call that on energy er value. Andi, Um, let's make a manager, which caused them, um, pin number, which we connected to pin unlocked in one so and pin it was a poor tench who meter and thin is a to Andi. Um, we need another knowing you to float because it's decimal. So that's where we use flowed, not injured. Um, which iss the actual result that we will receive. So that will be, Let's call it, uh, it's called V one. Yeah. Now let's in the set up section that start our serial monitor serial duck begin 1006 100. All right. And now we have an A long reach. The potential army europeenne. No, we have to calculate some stuff, so Oh, no, Sorry. Sorry. Do end value. Is that a little breach on potential in Europe in So that's the value will receive from the potential meter. That weapon value will be is something between 1,000,023 0 So we have to convert that into , um, 0 to 5. So, um, rise. The one is zero no. Five points divided by 1023 times the value we will get from the from the potential meter. So we have, um we have the value will be something between, um 1023 on zero. So we get rid of that on get five something between zero and five. I'm sorry. We get we have to write point here because it's ah decimal number. She right? Only write it without a dot and will think it will think that it is an imager on the result will be an end or two. And were You want the decimal decimal places do, so we'll write a dot on. Um, yeah. Now we want to see that in the serial monitor. So serial serial dot print line. Um, the would be one. Okay, Another thing. Um, if you don't get that, if if we receive 1023 from the potential meter, this will be the highest number. So that means we will get five. And if we get zero from the potential, ometer will get zero. And if we get on, say, 505 100. 0 10 Then we will get something around 2.5. So it just converts the distance between 0 10,023 to 0 to five. All right. And then we just, um, serial Print that to see them on the show. Miter, we should be good to go. Let's check it for, you know is connected. It is. Check the code. The code is fine. That's uploaded story to the arena. Okay, for just that opened the serial monitor. Andi, it's not looking. Okay, all right. I made a mistake. I'm sorry. We put the potential meter in antelope in one, and I just had it in, um, been too. So foam. Yep. It's right again. Oh, look, a serial more your There we go. If we change the potential ometer, we will see the number changed too, to something between zero and five. Uh, show me that camera. Okay, if I changed that to call all the way to zero, and if I turn it back slowly changes to five. All right, So in the next video, we will learn how to use that with an led holding criminality. So you see, in the next video 12. dim a led with the Potentiometer: in this video who will learn how to dim analogy with a potential meter. Okay, so let's take our previous circuit with a potential a meter. This time we want to dim one led. So let's take our led on and, um, pluck it into the brad board. We need, of course, a resistor to make sure we won't damage the led, um, 220 homes should be enough. Alright, here we have for resistor. Now we connect that short Catholic lag to ground off the arena, okay? And the long, ano black, we'll connect to digital pin, see these digital pins with, um, think of in front of it. We need to put it in there because we want to dim the led. So that's put it in visual pin 10. Okay, so let's switch the programming part. All right, so let's program it. We have our, um, led pin TEM. So that's an imager. Um, Allah, deep pin is 10 on our, um but then Jorma Turpin is at on look in one. So and on a lot and And Okay, so we have our circuit now on Let's program it. So are led this and pin then. So the other deep in it's a manager is 10. And we have the potential ometer pin 10 kilometer pin, which is, um, at analog one. A one, capital A. Okay, now we have the value we receive from the potential ometer, which will be between zero and 1023. Um, and we will have the the and result, which we'll have to convert Teoh between 01 255 for them. The led. So that's called that V one. Okay, let's try that first without cereal monitor. So we have to start the serial later. 9600 for age on. And now we have the value. Is the, um on the log Read potential murder pin, then? Yeah. And, um so the value will be a number between 0 1023 Now we have there. Result the one that will be, um, 255 dot because it's a decibel number. Sorry, we have to. Doesn't It should not be an end in an injure chippy afloat because the decimal number. So we have 255 divided by 1023 times, um, times the value. So if The value is Let's say if we turn the potential ometer to the right, it will. It will give us the number 1023 which is the maximum on then the value is 1023 and we have 255 divided by 1023 dot So if the value is 1023 and we have divided by 1023 our, um, and law, right, Jim, the led value will be 255. That's the maximum number, and that will be the brightest. The allergy will be a sprite as possible at that point. So right, cereal print line. Um, V one. Okay, let's try that. Rellenos connected. Check our code, Kotis. Fine. There we go. We have 255 and if I turned that to their eyes, it will change to zero. You show you that. And if we change the, um um the ground and the five balls, it will be right the other way around. So if we, um, have it completely turned to the rides and no to the left, it shows right now, um, 0 255 And if we pluck that in It will show, um, 255 if we turn it completely to the right. So you can just change these These, um, five volts and the ground. It doesn't matter which way I'm just make sure that your potential murder is split in hard enough because which, if dozens doesn't stick good, it will like it will give you weird values. So you have to press pretty hard, and then everything is all right and you can see changes to 255. Back to zero. All right. Okay. So, no, we see this working perfectly fine on now. Let's do that with led. We're pretty simple with led. We just need Teoh on a log. Look right, l a deep in. And now, um, the value. The and value V one B one that should Brooke for all led coat. It's fine. It's uploaded that already, you know. Okay, that's working perfectly. We'll show you that here I turned to the right. We'll get brighter and brighter, and if I turn it to the laughed, will go off if it is zero. So it is a value between zero and 255 on the higher the value, the brighter, the led. And we changed the valley with a potential meter. All right, that's it for this video. I hope you understood that. See in the next video. 13. Servo Motor introduction: hello and welcome back to the course of party. I guess you always wanted to know how to control Motors with an arena. So let's get started. Okay, so let's start with the serval motor. The circle motor. It's super nice because we don't need a such hold H Memorial Teoh to use the server mortar because it's very low powered, and we can connect that to ground and five wards off the order, you know? So let's take that thing hours. Um, connect that to make sure that we actually see when the serverless turning congest Put one of these from the server and then you see concerted. It's a 3 60 servo, so that's pretty nice. Um, let's connect it to the arena when we have the brown, the brown wire, which is the ground. Only use a black wife for that. Then we have the red wire, which is five balls, and we have the kind of orange wire, um, which is the the wire to actually, um, connect the server to order to the ari? No, on, um, turned the servo. So the server is not a DC Motor. The servant border. We can turn it to a special angle like that in Turn it 50 50 to the left or 50 that arrives . So let's connect the the yellow wire to pin through the digital pin. Um, nine off the order, you know? No, we have all the serval connected to the are you know, it's It's very simple. Um, super nice motor, which you can use for a robot arm or whatever. If you need a special certain angle return, you would use the serval mortar. So let's which the programming part. All right, so let's program the serve a mortar. First, we need to include a library to, um to actually turn the server. Motor libraries are just special sketch. They, you know, they let you that provide extra functionalities. That's why we need him for the servo. So lets include the serval library. You check. You can just go on tools. I know on sketch under include library. There's the serval section and complete the survey library. Andi? Yeah. So let's call or servo from server one. Preserve one on. Um, no, we have to tell the already, you know where we connected the serval. So we have it connected to pin nine, Server one, but attach nine. I'm just going to leave that on, and, um, let's turn the servo to zero degrees. It's called Cerebral your serval name and then appoint rice that's certain to zero degrees on. Then we can start with our code so we will lose. That will use to four functions for loops to turn the serval from 0 280 degrees, we need an imager. Let's call the imager angle angle. IHS zero angle is smaller. The 180 on and angle plus plus. Make sure you don't forget these brackets here. Um, yeah, I know we write servo server one right angle, so we have the imager angle, which is zero at the at the moment on. It will always increase by one. Instead of that, you could write angle this angle plus one. But I usually ride angle plus plus because it's a lot faster, so the angle is zero at the beginning on it will always increase each around it. Will it increase by one until it's 180 so it will repeat this loop 180 times? Um, that's right. DeLay 15 because we don't want to fast to happen So our angle were zero at the beginning and it will turn all the way. 280. So it's 40 that it's one. So it has one round through the loop on each rounded will wait 50 milliseconds. So when the rd no finished that code, it will go to another four. Loop and angle is zero angle. Oh, no, sorry. Sorcery. The angle is 180 now because it turned 280 obviously from 0 280 No, it's 180. Who wanted to turn back to zero? So, um angle IHS bigger than zero angle minus minus. So now that angle is 180 on a slow long as the angle is bigger than zero, it will go minus one on. Then we need the servo to turn. So serve one points. Rights the angle. And we wanted to wait 15 milliseconds again to make sure it doesn't turn too fast. That's actually so that's check If we did any mistakes, obviously not. So let's upload it to the order, you know, Let's show you this. We have a servo here and it turns all the way from, um 0 280 Have done back again so we can increase the speech. Let's say five milliseconds here, too. Upload the coach and it will turn much Foster now three times. Foster. Boom! Yeah, All right. I hope you were successful on, um and next video we will. We now know how to use the potential meter at the next video control of the serval mortar with a potential meter. So see you in the next video. 14. Control the servo motor with a potentiometer: in this video, we will control the serval motor with a potential murder which we learned in section for Let's get started. All right. In this video, we will need a brad board are really know potential meter serval mortar. Okay, on a few wires. So let's plug in the potential ometer. First. We learned how to use that in, um, sector for so we should be good to go. Let's connect. Opened kilometer first. Um, let's connect the, um, the one leg at the top to and look up in one on the other two legs will connect to the five volts and think of the ground of the arena are on one sick. We will actually will use the ground off the arena on, um, connect the whole row. So we have more pins. Um, foreground. Two years now? No, we can just, um, Look, the janitor to ground will do the same with the five worlds. Five volts into the plus a row. So the whole plus zero is five volts known. Connect the left black to the five volts can No. We need our, um, several mortar that we have the brown wire. All these believe for that. The brown wire is ground. So put it in the minus room on the Reds. The red wire is, um, plus five worlds, of course. So didn't you, though? Five waltz around and third, Third orange. Why're is to the connection for the already in in. Let's use in nine pitches open nine again on. We're ready to program it. All right, guys, let's program it. We have our standard program. Um, for the potential meter, we have the manager for the drama Turpin, which is a one. So and canned geometry, er you can is a one. Then we have the end value. Yes, the interval. You for the for what we get from the John Mayer. Then we have ant everyone, which we still have to calculate. And, of course, don't forget to include the servo motor library, which is under sketch include library on server. Then we need to call our servo name. It's a so servo. So are suitable is conservative. Um, we need to attach our servo too. Opinion. We got tested to pin nine servo. That nine. Um, let's let's, um, turned the serval to the position. Zero. Um, no, we have or can Schompeter again. So value is, um, on long read. Um, potential murder pin Andi B one is now we need Guess what we need in the video. How to control the led with a potential meter when you 255. Because the led the brightness off off the led is a It's the distances from 0 to 255 on this in the servo that distant this from 0 to 100 80. If it's if it is 180 degrees servo. So we need 100 a. G. Huh? 80 now divided by 1023 times times the value. Why, it is 1023 I explained about in the previous videos. Um, yeah. So we get a value from from 0 2023 from the potential meter. Um, that's what we need to divide it by 1023. Um, no, you have to tell the servo too. Servo rights. B one. Um so this will be a value from 0 289 on and we want a value from 0 280 to tell the servo what to forage in turn. So that's what we want on. Let's check the code. Good. It's fine. So I will connect my already. Okay, upload the coat. Done. Uploading. And now, if you turn your potential meter, the servo should turn with your potential. Ometer. Oh, sure, yet Well, that wait both something like that. Okay, better see it. So the serval here, gentlemen are here. If I turned the potential meter, it's pretty hard to show. But serval, it's turning with it. Let's, um let's make a delay so that it will be more accurate. It's kind of doing crazy stuff right now. So, Jill a let's say 10 milliseconds should be enough. We tried again. Upload, coach. All right, Most working better. So if we turned the potentially only to know the server motors were turned that well, that's pretty hard to turn. Yeah, but you can see it if we turn the putting thin. She all meter the, um, the server motor turns with it. Okay, So I hope you, um I understand that on seeing the next to you 15. Joystick Circuit: How does a joystick work? A joystick is actually pretty simple. All it is, it is two per country or meters and one button in a case. So if you don't know hope, But then she vomited. Works. I would really recommend you to go to section four and watch the video about the put in jail meter. Okay, so let's make a circuit. Um, we have 1 10 kilometer here. That's the, um, central AG, which goes out of the potential meter. Okay, Now we have a second within geometry, er, and that one has the central lags well, which we will connect to analog in. And the thing about the joystick is they have, um, one common five volt leg and one common zero. Vote means ground lag, so Oh, don't forget the button. The bottomless healing. That way you go, which is called switch for a show. You the joystick. Take that off. You see the ground and the five volts. And down here we have the switch been, which is the button? Okay, so this one is the five volts black. This one is the zero old slag. And here we have the switch, which is just a button. Who will connect that, um that, like, here to a digital repent a digital p. I mean, on if you look at it, you can see the potential meters because they on There we go. So I don't know if you can see that, but if I turn the joystick like that, if you return the jaw, Zigler, you that you can see the potential ometer turning. And if we go to the other side can see the other potential meter. And if we turn it again, you can see this one turning. And if you you can also press the I'm Joyce sick. I don't know if you can hear that, but if you press the joystick, you can see sort of button here. It really looks, um, like a button like a normal button which really used with the led on the thing. That happens if we press the joystick, you can see that small like here, which presses the button. And if we press the button, it will connect. The digital there is open to ground, and we will have a signal. So if we turn the potential me like that, that will be left and right. We have V R X v are X on. If we, um, move the joystick up and down, we have, um focus. We have v r Y, and that's that's just the switch pin where that's how the But it looks like So we have, um, S w that's the switch. Been Well, what do you use the potential ometer at the joystick? It's, um, if you control ah, flying object or a car, you know, it's it's much easier to use joystick. Let's say if you go move it left and right, the plane would go left and right of the car. If you up, up and down, the plane would go up or down. Um, that's much easier to use the potential ometer to control the object. So, um, that's a really nice thing to have. Okay, I think we were pretty good on ready to connect the potential ometer and program it, so let's get started 16. connecting and programming the Joystick: All right, let's connect our joints. Each of you already know. So let's take a joystick. Needs. 12312345 Wires. Okay, I'm sorry. Okay. We have the ground pin. We'll use just a dark Uighur on we. We have the five balls. Then we have we are X. We are why? And has w which is the switch been slash the button. Okay. So grown. We just simply connect to ground on five worlds into the five gold pin. Okay, now we have the V r. We are expert in, um, we we connected the potential ometer to the analog in pins off the Ordina. So because the VR x and we are, why are just potential emitters as well, we will have to connect that to the analog pins as well. So let's connect these so unlock zero. And for the v e r y se analog one. And now we have the buttons witch pin. That one is just ah, regular pin regular busing that be like usually connect to the digital pin. Let's connect the two digital pin nine or eight major. Okay, so we have it all connected. The button to the digit open. The potential are meters, so that should be our X. And we are Y two analog on five volts to five volts and ground to ground. Okay, I know we're ready to program it. Okay, so we have our button or switch off the joystick at pin eight. Let's make a few variables that will. That will help us a lot. So, Manager button, but in state bomb, small hints if you I have to write variables that are more than one word, I would recommend you to just write second word with a capital letter. That that makes it much easier to read. So you have like that. It's much harder. It's right. A capital letter. Okay, then, um, we have the b r. Sorry. The VR, um, wipe in, which is the the 11 of the potential meters and the joystick. And we have the VR X, which is the other potential meter. Okay, was we always do with the buttons. We have to declare them as input and puts pull up okay. For the analog, we don't need to declare them as input. We just swat them here. So, first of all, we need the pin here on and no, we need to use the button state variable, which is digital for each eight. So the button status digital reach eight, which is the pin off the button in the joystick. Andi, the b r Y state is analog read in. Oh, you are. Why is on pen that's your access in a one So on And the the are ex state is on a log rate. A zero, I think. Was it yes, that's the A 01 You could also use variables and set up these pins. You can just you could just some create very boss. Let's say, um, we are Why pin it is one that's manager and also imager. The are X pin, which is a zero can no one can you use but the pins and stepped off the actual pin numbers . So the are why pin v e r y pin is a one. So we have and lock agreed to be our pin. Would you say one and the same for for the we are expert in so we have the are backspin. Okay, Now we need the serial monitor Serial begin 9600. The rights, Um, the the potential murderous or the joystick v r y nvr x. They need to be an a la crete and not digital read, because we have a value between zero on 1023 and the digital REIT is only for high or low, which is the button. Okay, so, no, you ride cereal point, print line. Um, be our Why date on. And, um, now, cereal. No print, Not pretty. If if you write print line, it will, um it will write it in the next line. And if you just write, print it, will, you know, go next to the thing you have before. So we have we have view. We are White state. I will write that. Make sure you have it like that. If you leave these, it will think that the R Y state is a variable and just put the variable in the into the serial monitor instead of the birds. So this these are just the words This is not the variable. This is the words to help us to know which number comes with which words. So now we have v r y stage okay and now we use the variable. He are. Why state? Okay, now cereal prince line the are ex state and then cereal Print the variable. We are ex state. On last, we need the the button which iss the button, but in states so cereal dot print line, but, um state Oh, it's button state and the variable. Okay, so this what it says first on the serial monitor won't be a variable. And then after that, we will have the variable permitted to those serial monitor the same with the other two. That's not a variable on. Then we have the variable, and then we have the variable here. Okay, Can see. That's kind of blue. So that's not a variable. But we will still see that. Let's check if the code is right. Oh, sorry. Yeah. Um, if you see if you look down here that that small window if you have a narrow message If you did any mistake in the scope and the coat it will search. Always show it here and I wont upload it. So struck again. Check it. That looks pretty good. Okay. He used the already know this time, you know. You know It's a blow that awesome to go to a serial moisture. Oh, no. Let's make a delay. That's way too fast. Okay, so let's write everything in the next blind, so we'll just change that to print line. Then it will print everything on a new line that should work better. Okay, code. Let's check that. Okay, that's much better. Um, we see the button state is one because we didn't press the button yet. The VR ex state is 525 on the V. R Y. Status 500 for, um, so they're in the half off 1023 because they're in the middle, obviously, and not turn to the left or to the right. So if we turn them to the left, it should have 1023 or zero on. And, um, if we turn the other one, the other potential murder up, it should have 23 or actually, 23 or zero. So And if we press the button, it should have zero. Of course. So let's check that, Like Choi groo. Whoa. Oh, Okay. So if we turn the, um, the joystick, you're the left. You can see VR X stages 1023 now. And if I turned the joy see to the right, the Rx date will be zero. There we go. And if I turn it up, the VR y state will change 2023. And if I move it down, the VR Y said Will has zero. Now we can press the button. If you press the button, the button state will go to zero. Yeah, we can. We can press the button and move the joystick. So that's no problem on you. Always see the variables changing. Okay, I hope that Mike Sense on in the next video we will control a serval mortar with a joystick , So see in the next video. 17. Control the servo motor with a Joystick: Hello and welcome back in the course of party and this video, we will learn how to control a servo mortar with a joystick. Let's get started. Let's take our previous circuit of the joystick. Um, you didn't watch the last video how the joystick works, Police. What's dot That would make it much easier to program the cerebral with a joystick. Okay, so, um, we have ground to connected to grounds five holds too high vaults off the arena. Then we have the Rx, which is connected to, um and look pin zero and V R y, which is connected to analog pin one on a switch. Been off course that is connected to the digital pin. Eight. No, let's connect with a serval. Mortars, Bardina. Okay, here to the dark brown pin goddess ground, we have the red pin, which is five worlds it's collected. We don't have a 2nd 5 volt pin on the arlena, so we will have to use a brad board. Okay, You know, we pluck in the I'm sorry. Hell. Blue wire for five golds should be a red wire. You have water. Add wire. Useful right wire for the fire for the five bulls, so it doesn't get confusing. Okay, now we have the row, which is far votes on. We plug in the 5/4 off the joystick and the final balls off the several mortar and the ground off the serval moral connected ground off the gardena. Uh, the then we have in here. Let's just connect there to pin seven digital pin seven. All right, so we have the pin off the serval motor to pin seven on the joystick. Um, before also connect the Jocic Sardinha. So let's switch the programming part. All right? As I told you, the joystick is nothing but two potential meters and one button. So we have Teoh program it pretty much the same way as we program the potential meter. So we have the V R. Why value? No, Let's say the pin, Which is Oh, the VR wiping is up in a one. So we haven't Manager imager. You're wiping is a one. Well, what do we need to do? We have a serval mortar, so we need to include a library. The serval library Looks like that We have our serval library. No, we need to give over serve or name. So our server, let's call it servo test servo. So that's the name of our servo. Now we need to tell the arena where we connected the servo. So the serve old daughter attach on a pin seven. And now we have to on a log, read the value we get back from the joystick. So how far we turn the joystick means how far we turned the actual potential meter. So we need to get the value or the voltage out off the second resist. Remember from the potential meters video. So analog raid. Let's let's give it a name. Let's say imager we are Why value? Well, you So the are why value IHS at a log, read the are Why pin So the value is analog. Read br wipe in, which is a pin? A one a lot one. It's analog read because we have not only higher now we have a number of between zero and 1023. No, because we have a serval mortar. We the number 1023 The number between zero and 1023 dozen really help us. We need numbers from 0 280 So we need to convert the the actual on a law degree value off the joystick 20 20 between zero and 180. Value is your 180. So it's call it, um, manager for assault. So our assault is Oh, it's it's not a manager. I'm sorry. We will get a decimal number. It's afloat. So we have decimals on result ISS 118 divided by 1023 times the the are why value. Okay, so if we get 1023 that's the highest number we can get. That would mean that our servo needs to turn completely to the ride 280 degrees. Um, and if we look to the result the float, which is a variable, we have 100 80 divided by 1023 times the VR y value. And if if we move the joystick to the right, our survival ship moved to the right as well. So, um, if we moved to moved it to the right, r b r y value will be 1023. Well, what? It's 180 divided by 1023 times 1023 180. So our servo will move completely to the right. Okay. Okay. Now we have to tell the serval to actually move of the amount. So test servo, right? The result. That's the whole coach. So that one is Just tell us the servo to turn the value between zero and 180 which is a result. The very well heeled kills. Check the coach. Everything is right. You're connected to the already know that's uploaded. All right. Show you that. There we go. I have the joystick here at the server. Mortar on the left. If I turn of the joy, see to the left. The serval mortar moves there left as well. If I move the joystick back to the middle, the servo moves back to the middle as well. And if I move it to the right, Oops, there. Right as well. So in turn the serval pretty smoothly. And it's actually pretty accurate. All right. I hope that makes sense on seeing the next video 18. Detect Position understanding: Jones worried We're not gonna draw circuits today. This video is all about the, um till balls, which looks like that. It's pretty useful to have if, let's say you're building a robot and the robot takes a turn and falls on the side. You wanna use someone you want to know that the robot is on the side? So that's why you would use about till balls. Which, um, you can hear that. I hope you can hear that. I'm not sure that, um, ball in size the case. Um, the ball is like a conductor. Weird. It my parents algo. It's kind of use that one. Um, Okay. Good SE works like that. We have these two legs once plus in one is minus on. Then we have that case. And inside that case, we have a ball. Well, one leg, it goes to, um, the digital pin or just five volts or whatever, and this one goes to ground cannot. Five volts. That's a bad idea. Um, let's say to a digital pin goes to digital pin. Okay, Um, and we say the digital pin is high. I hope you can read my writing. Okay, so we can like that leg to the digital pin and that, like to ground on. And, well, if we if we have, um, the digital pen is high. Onda. We connected this to ground. Then there is electricity going from the jitters a bone, the digital pen to ground. And, um Well, if the uh huh gonna draw another one like that so we have it on the side. Kind of maybe a little little turned a little down so the ball would be here on this is still connected to the digital pin, and this leg is still connected to groaned. But we have no electricity here because the conductor does not connect the digital pin lag to the ground pin leg. And in this case, if we have the tilt like that, the, um, conductor bowl connects these two lacks, and in this case, it does not connect these two legs on. Um, if we would measure the digital pin, we would get a different Well, you that if we would measure it at this state. All right, 19. Tilt Switch programming: Okay, so we connect the tilt to the brad word. Um, yeah. The tilt basically works like a, um, like a button on Lee that you change the state. Very tilting. Okay, we connect the tilt to the bread board. Okay, then we have. Ah, they just open and a ground pin ground pin goes to ground. Is that ground? Yep. That's ground on the digital pin. Let's go to seven. Okay. We got the digital pin seven on ground that said all. You know what? You want to connect? A green led on Also a rat led. I used to Ah, ladies, this time why we need to, Ladies. I'm gonna tell you later, So we need to 220 homes. Resistors. I just want to make sure that that is minus lag the death att's just connect to the minus row. And this is also the catheter on. We connected to the mine is relus. Well, okay, now we need to wires the green led. Let's say it goes too. Did soap in age spend The red led goes to pretty small wire. That song the red allergy goes to Mom. Let's put a to digital pin nine. And we have ever Oh, no. We don't have everything connected. We need to conduct the can. Actually put the tilt also into the minus row. Now we can connect them Linus Roe to the grounds We have less ground pins ground. It's here. Here we go. Everything connected. Okay? Huh? I don't know what that some waas. Okay, we have imagers. We want to keep it organized. So, um, we have an injured for the green Valley. Deep in what? Just pain. Right? Eight. This h then we have imager for the reds led pin. What is just pin nine on? We have another pin. Fruit are tilt. Just visual. Pin seven. So, um, tills the pain is seven. That's all we need. Okay, We need Teoh. Make all of these pins outputs soap in modes. Um, green Ali G thin output and nodes, breads, led pin output. Um, pin modes, Teoh pin output. You wanna have the tope in output? Because, um, Well, because we want to give the Tobin energy on if the tip in. Yeah, I wanna get to the energy to the open to make sure that we have that we can check if electricity is going to go through the till ball. So writes. Um right. First of all, digital brides tilt thin. Hi. It's always nice to check with the serial waiter. If everything is working serial begin 1600 on No, we digital for each The till pin would just and seven making another another manager Tilt stage. I'm just right. Tilled stage is official rate seven and now we want serial print the tilt stage. I'm Yeah, Let's check man a mistake. No. So get uploaded. Schools, cereal monitor. Yeah, it will say zero. Um, if we have electricity. So if the ground and the digital pin are connected, we have zero and show you. Though, as I took us, you can see that it's which is 21 Because grounds on the digital pin are not connected anymore on. And as us we turn it back, we'll switch back to zero. Okay? What we wanted, you know, is it's so no if she if if until state IHS zero, we want to make, um, the green allergy, we're gonna turn it on because until it is not tilted turned. So one of to know the chronology so digital rides Green allergy pen. Hi. And make sure you don't forget that the rest really deep in has to be looked. Okay, well, else if we don't actually eat if but else if the tilled stage IHS one. So if we turned the tilt change to one cause the metal ball conductor doesn't connect to ground. And, um, the digital pin, then we wanna turn the red led on on the green. Led no, on Redd's led in. Uh, hi. Okay, so if it is turned, we turn off the green led pin. Turn on the readily Let's check. It's good uploaded. Go show you that again. Pretty hard to see And okay, so you can see it is green right now. You can see this green right now. And if I If I turned them, that will change Your, uh Still, it's still 000 And as a changes to to one changed because of the light direct on the green led start off my back screen this way. Threat. All right. I hope you like the project. Oh, it's no real project. A little project. See in the next video 20. Sound Sensor with an Led: Welcome back to the course of our here. This will be a pretty nice project. Will use some center to listen to music and to control it led without let's get started ways Way I Okay, let's connect this song sensor first we have a digital pain A plus, a ground and unlock pin. Um we will use the digital pin. The unlock pin is not really necessary. So digital pin Then we have the plus five bolds pin. Okay, let's connect the digital pin to pin seven and the plus five volts Teoh five of bolts Of course from that side. Come on the ground with which is G We connect to ground authority Now what? We also gonna d We will connect on Ali G. Okay, so it's used the bread lord have the and out on the cabinet leg Catherine goes to minus. First of all, we need a resistor. Resistor should be 220 homes. We got the plus and the minus. I'm Let's put the plus off the led to a little pin. Eight. 30 No, on the ground to ground. Here we go. Who's okay? That's all we need to connect the digital pin off. Um, the sun center goes to did a digital pin. Seven on the led visual pin goes a digital pin eight. All right, all right. As usual, we need a few injures One imager for the led pin, which is connected to pin eight solar deep in minutes. H Then we have a manager for for the digital pin off the song sensor, which is schedule pains seven and sound sensor pin IHS seven. Okay. The sound sensor pin is what, um, input, Of course, because we wanna get a value a high or low. That's what digital. That's what we connect it to a digital pin. Um, yeah. So pin mode sound sensor pin inputs on a pin. Modes led Pim, I would push. We don't want to get a belly off the led. We just wanted to go to controlled Led. So let's hope, but okay. Oh, need another manager for the sound censure. So sound sensor Faried is no digital read, not an a la Crete because we only want higher or lower digital re on the sound center Pin song Sensor thin. No. If the sound center pin the song sensor read sound sensor read, IHS. First, let's check what values we get from the sound sensor. So with a serial murderer, still cereal begin 9600 serial print line Sound sensor bridge. Okay, it's take cable on connect the arena to, uh, Casey. Thank her. So we got zero. Um, I'm going to show you something. Okay? We have the sound sensor here, and we need a screwdriver, something because you can see there is a potential meter and its purpose is to change the sensitivity sensitivity off the sound center so you can see this led here, which is called led to on the solemn censure. And if we change the potential meter, it will change that sensitivity. And you can see that led to it's on right now. We want to make the when we want to turn it off by turning to the left. It's pretty hard with one hand try and on eso think that's pretty good. So yes, kind of blinking. I turn it to the right. So the allergies on, But we wanna turn the led off. So we turned to the left. And if we turn to the left, we can see not the allergy is off. Buts. One up. Um, have the allergy blinking just a little bit. So should blink. If you make it sound like that, it's already do that. But let's turn it back. So it's gone and one just turned a little bit. So it's off. We're just just just a little tiny bit so on. Still on. Still on off area. I think that's pretty good if you make a sound if you for something, you can see the ladies going back on. So that's what we want. And eventually it's clap or something. You can see on the serial monitor that it changes from 0 to 1 the serial morning or is super fast, so we cannot really see it. Sometimes you can touch the microphone. You can actually see it carrying 21 of them back. Yeah, and as it turns to one, Talagi turns on Okay, okay. But we want toe control the allergy. So we're right If I'm just gonna back to a serial moisture. Well, what was that? Whatever. Um Yes. So it zero Andi, if we make a sound, it turns to one. So if sound sensor read, IHS zero know if it's one. So if if we have a sound you want to make the allergy turn Ali eso digital, right? L e g pin Hi. Else if the sound center well, else they can. If it's not one, the only thing it can be a zero because it's a digital We digital read it so it can be 01 else Digital, right, Ali, Deep in no low. Because if we don't make some want, make sure that the allergy stays off And if we make a sound to turn on Go turn the potential Mineral Little just recognized that it was too far right? E think that's pretty good. You know if what upload the sketch If you clap, you can see that the lady build on show you Not again. Think you can see it? Okay, we have sound sensor here. And if we club, you can see that the l. A He goes on. I would try something. Um, have a blue jeans speaker here. It's gonna put that on the side place a music no one owns on. Turn it a little to the right. Yeah, that's the only bad thing about this. It's very sensitive You have to play a little little bit around and see what the right position is for the sound sensor. Yeah, I think. Okay, now we can play some music. Ah, one second. Here we go. Come on. Okay. I think you understand how that works. You have played around a little bit with the song center. So you have there. I sense a sense of sensitivity. Yeah, whatever. Um, in the next video, we'll use the song center with a metrics, so yeah, See in the next video. 21. Sound Sensor with a Matrix: Welcome back to the course of already know. And this video will control Matt Tricks with a song sensor. Lets get started. All right, We already connected. The sound sensor could see the d zero. It's a digital pin on to be connected to the digital pin. Seven Authority. No, no. Let's get the Ma Trix. Okay, there we go. Um, we have the ground. Andi on the VCC, which is Piper Volts. We don't have enough five volts. Been on the rdn owner. So we need to you to connect to the five or to the classroom and connect the five volts off the sun center. No, we have connect the metrics to the five volts. Just the white wire on the black wire. She Andy goes to ground. We have enough ground pin, so Okay. No, we have d I and which goes to, let's say, digital pen 12 digital pin 12. We have the CS, which go to which goes to, um, digital pin. It's 11. Huh? On. We have to see. Okay, which goes to digital pen? That's a 10. Okay, Got all connected. Now we can switch to the programming part. Okay? I already wrote the coat for the metrics cost again. It takes a long time to write it. And the video gap pretty long, so yeah, but I will explain it to you. I wrote up there. The pince off the metric So d I am is connected. 12 CS 2 11 and see OK to 10. Need to include the library for the metrics. Then the boys set up. We need to start the on the metrics. So, Shep, downfalls. Then we have the, um the brightness off the metrics. I think 15 is the max value, so I put it to 15. Then we clear the display. Don't. Here. I have a function. Um, you can just copy that into your coat. What does it? Um, it's rights. The bites on the ma Trix. So we don't have. Remember, in the last metrics video, we had a lot of the southeast Central Satya Row. Um, instructions? No, we need only one with a four loop. So that's much easier. Now the function is called display. Bite on. We haven't are a here. The barometer, so we display by display on display is an array here. That's the worry from it. Just says, which led ease are turning on If we, um if we're on the coach. Okay, so it's pretty similar to the L A G Song sensor video. Previous video. It's pretty similar Onley thing is that we have the Patrick's instead of the led looks better when you have few imagers. Manager for the, um, for the digital pinging off the sound sensor. So sound sensor, then is the pin. We connect it. The Sound Singer, which is digital pins. Seven. Yep, So seven, we have a manager for the sound sensor. Great. Let's call it read again. Great. No, we need Teoh pin mode Sound sensor, then inputs because we want to read the state The digital state high or low off the sun sensor So it's input on land we have How do you call it some sensory sewn sensor? Bridge is digital Great. The Sound sensor 10. That's Ancestor Regis Special redzone sensor pin. Let's start the serial and later on, see if everything is working Fine. So cereal begin 9600 on the void loop. Just gonna make this as a comment. So, um, already already does not around that sect, that part of the code. Uh, done. It's on sensory serial print line. The sound sensor. Eat. Okay, let's check the coast. Who? It's all about debugging. I know we can upload it. Didn't connect the Arduino. There we go. Done. Uploading Check the serial monitor. Okay, the cereal. Morning looking the It's on sensor is working. Fine. Now we can changed about back on if this sound sensor read is one, Actually, I'm gonna write it down here if sound sensor IHS one So if we have sound, we wanna We're on. We wanna display display the turn on the metrics Second bracket So if the sun If if we have a sound return on the bracket else If we don't have a stuff sound then we clear the Ma Trix So you don't have a sound, Cleo. The metrics. Checketts. So selling Sancho was not grow. Sorry, son. Centereach. All right, go can upload it. Okay. No, we gotta play around a little bit with the potential meter with the sense of sensitivity off the, um off the audio for some cancer. Okay. - Okay . I think that's pretty good. Uh, it's a okay in what looks pretty good way. Yeah, play around with the kilometer. A little bitch with a sense activity off the sound center. And you should get it. By the way, I'm sorry if you didn't like the music. 22. what are LDRs?: Did you ever think about how streetlights? No, but it's dark and when they should turn on. No, it doesn't matter. That's what we learn this section. 23. understanding the LDR: all right. In this video, we will learn how, um how on LD r resistor a light dependent resistor works on and how to use it within our dinner. You know, if you can see that pretty hard to focus, but I think And corrections here, Stoute Long blacks that. Yeah. So it's, um, pretty similar to the resisters you already know. Just the normal, normal blue resistors that we used with the allergies and stuff. But as the name says it light Teoh pendant resistor. You can. So what that means under a few diagrams. Name to understand that. Okay, What? That means it is a semiconductor semiconductor device. So it may it uses the same conductors what that means. Um, we have two bands that are very important, and I'm just gonna right here increasing energy. So that's the increasing energy on. We have the Sam IQ condo, doctor. Well, um, this thing represents our valence bands. Balance burned. And this up here is the conductor band conductor band. Um, the violence band is the outermost shell, often atom or molecule or whatever, Um, with the Valence electrons. So we have a bunch of electrons here, but we have no electrons up here and what we want to do in order to make the material, um, a conductor. We want out. Put the electrons from the Valence Band to the conductor band and we have, ah, forbidden gap here or energy gap. However you want to call it, It's between the conductor band and the Valence Band. The electrons cannot be in that gap so they can be in the conductor band or the Valence stand, but not between them. So they need a certain energy to jump from the Valence Band to the conductor band. Well, and the light resistor. The feature is that as light increases, the resistance decreases. And as light decreases, there is this sense. Guess what increases? Yeah, of course. Um, because it's a light dependent, a resistor. We have photons, which is light. So if light, um comes goes on our home L d r resistor the electrons, the photos excites the electrons to move or to jump TVA conductor band. So, like gods. No, my drawing skills are not that good. But however eso that's the photons, um, going to the electrons and the electrons than jump in the conductor band like the some Poland's here. There we go. And as we have more electrons in the conductor burned, um, the batter, the material is actually a conductor. So it conducts better if we have mawr electrons in the conductor bound and the electrons jump on on the conductor band. If, um photons, um, such speak shoot into the balance pan. So as we get photos from the light into the valence band, the electrons jump into the, um, conduction bent, and the material of the compound becomes the conductor I live. So let's draw a circuit with the, um, photo resistor. My goodness. Looks actually that also this Let's try. Sorry that that doesn't look very good. Gonna draw another one. Okay, so the arrow the arrows are the photons or the light coming into the light dependent resistor. This part here is five volts, because that this is connected to five voter to the arena on this one is to ground, which is zero volts of the arena. So this is zero volts and this is five volts. Well, the problem here is this will always be zero volts, and this will always be five volts. Oh, sorry. Yeah, so this if we try to measure that part, who always get zero bold and if we matter that part, we will always have five volts. So that doesn't really help us to get a value from the light dependent resistor. So we can add another just normal resistor. It will look similar to the to the, um, potential meter circuit. So we got the light resistor on the normal resistor here. Okay, there's this five volts and this his zero holds well, what? What part? Can we get a value from this one so it can measure that thing in the middle? That will change. Asked, The resistance is through. Is this your changed? Um, let's say we have five K homes. Doesn't really matter as long as as long. It's between one k ohm and I think 16 k arms should be fine. So five counts should definitely be fine. So its use five cape homes, um, on and we will call the the light dependent resistor R one on the five k home stores this year we will call it are to Well, no, we want to calculate the current because we need the voltage to Yeah, we need the voltage because the voltage is the only thing that the are, you know can measure. It cannot measure the current. So we need the voltage that will be here. Okay. You remember, homes Law is you is our times I us voltage or is there a resistor? And homes and eyes compare the current. Okay, so we need to get I So we divided by r Because our times I So you divided by r is I and you is five volts are is, um are one which can change. Plus there too. But our two is 5000 homes. As we know, not one doesn't change. Okay, so that's I bi folds divided by r one plus five fell zones is, um but we want to get the voltage. Which is you. So you is are times I we got I witches. Five volts divided by r one plus five 1000 homes and well, our is are to know. Sorry, are one we need to. In order to get that, we need to subtract the five volts minus the voltage that we lose with the photo resistor. So we get the this one. This part of the voltage of this part. So we have, Let's say no 10-K homes, ship foreign, So 10-K homes is something in the middle. Should be something in the middle. So it's it's not really darkens really bright on. We have to change our one because we said that our one is 1,010,000 homes. So we get to change our 12 10,000 homes. Well, we just ride that again. So 10,000 homes, times five volts divided by 15,000 Holmes, 15,000 only because 10,000 homes, which is R one plus R two, which is of 5000 homes. So we got 15,000 homes and we will get our voltage. Let's calculate that 10,000 times five divided by 15,000 which is 3.3 volts. Okay. Um, all right, so we got the resistor one here and through the resistor one, we will lose 3.3 volts. Okay, so we have, um, 1.7 volts here. This is 1.7 volts. If our one is 10,000 homes and our two is 5000 homes, but let's says $5000. Okay, It's 1.7. Owns because five volts minus, um 3.3 volts with which we just calculated the resistor One is so five fold. Subtract, Subtract it by, um, 3.3 volts s 1.7 golds. We have 1.7 volts here. That's what the R. Dina will measure here. Yeah, on. And the 1.7 boards will go away through the five K homes, so this will be zero boards. So that's true. Okay, let's make another example. Or, um, I wanted to show you something else. If the light increases, the resistance decreases and the current also increases. Because if the light goes up, if it the light increases, there are mawr electrons jumping to the conductor band and oh, yeah, they're resistance decreases and five volts are divided by a lower amount. So the current increases of if the light decreases that that current also decreases. Because, um, if the light is if the light degrees is, um we have, ah higher resistance because the elections from the conductor band to the Valence Band and we have ah, lower current because are one increases. So we have ah higher divided by number here. So the current decreases as well. Okay, let's make another example. We have five volts again here. We got zero votes here, which is thicker Down off there. Are you know? Then when we got our how the r resistor on and our normal resistor. Okay, let's say, um, our normal or resistor is 10,000 homes and the, um, lie dependent resistor is 2000 homes. No, we need to know the value here because we want to measure something which will increase or decrease. Depends on the lights. Um, we need again the current which iss five volts divided by 12,000 homes. 12,000. Only because 2000 homes on 10,000 homes to get there are 12,000 homes. So that's our current and compare not gonna cut like that. Um, Well, no, we want to know the voltage. So we need to calculate the voltage that we lose with the first resistor. Okay, So the first resistor is 2000 Holmes times the current just five volts divided by 12,000 Holmes, which is totally 2000 times five. We'll get a pretty small number, 12,000 arms. So that 0.83 volts, which makes sense because this number is pretty low. That means the resistance is pretty low. And that means that the light iss very high. Um, so we know through the resistor we lose zero point at three volts. Well, five volts minus 0.83 volts are 4.17 volts. So we get 4.17 volts here on. That's what the already knew will measure because that unlock input pins can only measure bolts. What we also can do, we can measure what? How many boats we will lose through that resistor. Um, so we have 10,000 Holmes times five bolts by 12 divided by 12,000 homes, 10,000 homes. Is the resistance off there? Is this off the second resistor on? Yeah, that will be, uh, 4.17 volts. Because we have 00 volts here and we need to lose 4.17 volts. We can just check if that's right, what we did before. So 10,000 times five, divided by 12,000. There we go. 4.16 it's pretty close to perfect. Yeah. 4.1 six. Sorry. We lose 4.16 volts. here, and then we have Okay, then we get zero votes here. All right, So, um, I hope that makes sense on that. It's not too much for you on what I see in the next programming part. 24. programming the LDR: okay. If we look at our circuit, we have the and look input pin here where we get the voltage. Um, depends on the first resistor. Um, I explained that in the last video on, we will connect the five volts to the resistor to the, um, light dependent resistor on. Then we connected to the inputs and log in in pin off the arena. Andi also to the second resistor, which we will use 10,000 homes and that it goes back to ground. Yeah, the light dependent resistor will have value. That's where a resistance that depends on the light. That's what we learned in the last video. Ah, Now we're ready to probe to first, though, the circuits and then to program it. Oh, you know. Okay, so let's take the the old er module or the resistor. Sorry and focus. Here we go and put it into our bread boards. Doesn't want to go in. I think that's pretty good. That should work. Um, then we have the and look input pin, which goes between the the photo resistor and the normal 10-K owns resistor. We'll just use a 10-K home, So take a resistor. You can see the resistance. Um on the band doesn't really matter how we connect ground. And for five volts, I would just use five volts Here goes to five volts on the ground. So we have five worlds in their own off the l d. Our here on. And then we have the on log zero pen connected between the resistor and the only Armwood Theo resistor. Then we connect this ground to the 10-K homes resistor ground. And that's our, um, circuit for now. Later, we will also add analogy to control the allergy with a lot dependent resistor. Okay, what you wanna do? We want to spur start the serial monitor. So cereal morning, I saw a serial begin I 1006 100. No one There we go. Okay, Now we need an energy er to track our states or the voltage off, um, off the parts between the, um How the resistor on the normal resistor. So let's call it imager. The voltage on and another energy the voltage pin IHS unlock zero because we have the been connected to unlock in pin zero. So a zero and then just right on a log voltage is on law. Reach both pitch pin what we wanted, you know, because we need to see the voltage. So we cereal print. It's on the serial monitor. Voltage. Okay, check it. That's right. Seems work connected. We know it's uploaded. Okay, You see him later. It's very brighter. I know. Show you. Um, there we have the the old er ma June right there. And you can see the the value, the voltage from 0 to 5. Baltar's basically converted to zero to 1023. So we have 800 around 860 a value between our own 860. Right now, it's pretty bright in here. If I take the hand and put it over the light dependent resistor, you can see that the number is dropping 250. And if I go back, goes back toe to 860 from Yeah. We learned that in the last video that the electrons jump from the balance band to the conductor band s Forget Mawr photons on the balance band. So that how it works, Okay, it's pretty dark. Well, whatever. Um in the next video, we'll add on led on and dependent on the light. Who will change the brightness off the allergy? Let's get something 25. Project: LDR combined with LED: all right. What We're gonna you know, we have the only are connected if you don't have the let depend. Resistor connected. Police go back to the previous video or the video poor. The previous video? No, it should be the previous buddy. I think where we connect the, um LD r But you can also see it here. Yeah, well, we don't what we're gonna do. You know, we want Teoh control of led with all the are. So if it gets darker, that led should come should turn brighter. Um, let's use a yellow. I think we haven't usually yellow and yet, so we're gonna use an area yellow I d. Blood bath and your bread boards. We will need a resistor. Oh, the resistance should be at least 220 homes. Don't don't want to destroy your Ellie. So resistance, um, so connected. The the small leg off the led to the resistor. Onda connected the resistor to minus which is ground. Connect that to brunch. There we go. No, we have that the plus the Anoat leg, which is Plus we need to connected to a digital pin, but with pulls with modulation. So that's connected to pin three, which is able to do that. Okay, so we connected the yellow led to digital pin three to ground through the resistor. Yeah, okay. Hanging out. All right. What we want to do is, if the light iss under a surge in value, we want to turn on the led. So we need a few imagers for, um, we need a manager for the Ali Deep in Ali. Deep in is three courses connected to digital pin three. Then we have, um, Edger. It is called the The Resistance Been Call it like that. It's been so that's unlock pin zero. So a zero a zero. There we go. All right. You need todo you to declare the allergy Penis. I'll put so in Moz, How deep in I would put we go Another manager for, um, it's called value. That's the value we get from the from the part between the l. D. Are on the 10,000 homes serviced er, so that's a voltage. So value is analog reach and a lot. Why? Because we don't have just low and high or high and low. We also have a value or we have a value between 0 2023 It's not just high notes, a value between zero in 1023. That's why we need an law. Agreed. Okay, analog reach the resistance Been which is a zero on Now if if the value is greater than, let's say 400. Well, van we turned the allergy off because of the lives. Ah is pretty bright on. If if we have light, we don't want the led to be on. So it is greater than 400. Um, digital digital right L e d Penn. Hello On If the value IHS lower 400 then we don't have a bright light. So it's dark. If it's dark, we want the led to turn up to turn on. That's all. The street lights also work. So balm, right else else forgot the brackets. Digital right, Ali deep. Hi. Okay, so if the value is greater than four on red, we turn off the led. And if it's not greater than 400 then if it's under 400 we turned the I returned the allergy off. That's jacket Expected initial Isar before 80 Oops. Don't make that mistake. That's a pretty awkward. Sorry. Okay, I upload. It began. That was pretty good. Um, if if I try that out now, if I turned the light off, the led should go on. Should I'm gonna show you here. Oh, turn those. I hope you can see that. Okay, take a second. Turn this light off. Go those laptop on. Now, before I turn this light off, you can see that the led goes on. But I go on, You can actually see that the led goes back off. Okay? I hope you really like the project. I think was pretty five. I don't see in the next video. 26. KeyPad: hope you're doing great. Today. We will use a keypad to write something on the serial moisture. Let's get started. Let's take our keep on. Like so I got and connected to the arena when we will need a few wires, you need to connect every, um, row to the already, you know. You know, for Rose and four columns warning on. Would one porn Okay, Can we start from the bottom? Let's put it to There's open nine from digital pin 92 additional open to this one to digital pin age keenness a lot wires. Unstinted show pins. Five for three. Um, to Okay, okay. We need to include a library. It's called Keep hat. If you don't have the library, go to sketch. Include library, aunt, manage libraries here. Then there will be a window pumping up when we search for key. Pint. Ah, scrolled down, down, down, down Down There we have it. Keep it by Mark Stanley. That's the one we want. So don't build that library. And don, we just want to include that library. We have to keep pot. What we want to do now we have a manager for roasts on. We have also uninjured. For columns. We have four rooms for come. So both are four. Right. More hopes. Okay. Also, we need to make array, which is charged or is just another variable which saves out letters. So it's called the char case. Keys for Rose. Andi columns. Okay. No, we have the first. Um all right, so for one and we have so just go for me that we have one, 23 a 456 piece and nine C and so on. So that's what we know what we need to do. Now the, um yeah, to three on four. We don't have four star. We have. Uh, yeah, they know. No, we can close the hurry. The part of that. Right now, we have other, which is 456 b. So for five. Six be knows that. No, we have 789 c seven. It's, uh, line. See? See? There we go. Then we have my goodness. Zero. How? Shack on D. So that's our array. Okay? We need another air, a bite. Let's college rope pins because we need to initialize the do you know on. And, um, when you tell the Reno toe, which currently connected the the keep odd. So by Trobe pins, right? Rose, um is, uh, Aerostar One seconds nine. It's a six. So the 1st 24 1st 4 pence are the rose. So we get pin nine eight seven on six. That's another array for Colome pins. Columns. Um, let's call the We have 9876 So we have 443 to 2. All right. For three to now we need to initialize the so keypads. Let's call our key patch are keypads. Call it whatever you want. So that's just a instructions to initialize The gave a keen key map key. Keep out. Sorry. Um, your kinks. So keys are the array up here And then we have rose colors. Peace. Ah, row pins column pins, Burrows on columns. I hope not, sir. Eyes that should be. We don't really have to worry about that. It's just to initialize. Keep out over one gene serial. Begin my 1006 100. You won't know. Oops. One of right the keep at the the letter or number that we we've pressed. We want to ride that on the serial monitor. So char custom keen you can call it like that is our keeper get okay. So that function from checks? If we if we press a key, what key it is, actually. And if we press the key, we also want, um if custom piece of repressed key, we want a serial print that key. So cereal prince line custom. Okay, Who counts? Check if we did. Um, steak, I hope I really hope we did not make any mistakes. We did, um, are bound. It's not an edger. Before breath it soak in what doesn't Not like, um, we can change that to a bite. Constant baj. Do you know if that's the issue? So that means that this doesn't change the number. Oh, okay. That was that was actually the issue. If we connect our early no, Teoh Percy can upload the coat serial monitor. So the keeper here, if a press number or letter should show up on the serial monitor she told There we go. I b c the 123 four for six seven age knowing castle dots working. No, no, we can use. Also you display can step instead off the serial monitor. Let's do that 27. Keypad with a LCD Display: we connected on the keypad to 30. Now on we could print the the things that we tap on the keypad will print that on the serial later botching this video we want Teoh. We will not print the things on the serial monitor will print it on the LCD display. Let's get started. Okay, so let's take our previous circuit with the keeper already connected. Um, let's take our display with ice Course in volume on convict Connect this one as well. We got ground, it goes BCC That goes to five holes on and we have S t a That goes to S d A, which is on the top of the Reno. Oh, um, that's the SDA pin I hear on the last been is the A C l, which is right here. Okay, connect it. All right, you start. All right. Let's take your previous coach because we don't want to write all over again. Would take will be a very long video since it is a pretty long coat. Um, okay. We need to include a few libraries for the ice core. See, on the outside you display So include library wire for the connection Andi. We also need the liquid crystal library. That would go liquid crystal. Um, yeah. So when you to initialize the LCG was proceeding module. Let's just do that under the library's so liquids crystal eyes where c it's called or display LCD. You know the address off our, um a power, I swear, Seymour you on and the dimensions off the display. Let's go to avoid set up Andi, That's right, all city and it start the LCD display. We want back light if you connect your order, you know, to a battery or something you probably don't wanna don't want the black backlight off the also you just play so you can just simply turn it off, but we will turn it on. So l city Dr Buck Light. Okay. You know, we started our also you just plain camera surrounding along. Okay, um, if a custom key is pressed, we don't want it to print on the serial monitor now. Wanted to print on the LCD display. So the dark print custom. Okay, But we need to sub the cursor. Such cursor. We actually want the cursor to jump to the next to the next part where we can print another another, another sign or another number. So we want the cursor to jump one forward and we will write it. Set off the zero line and line will be an injure and line is minus one. I will explain. Why does my is one in one second if custom? Okay, if custom key is if the custom key is C So if we pressed See, we want to delete everything on our LCD display. So we write. LCG, John. Clear. Okay, we clear everything, and we just set the cursor back to the beginning. So set cursor. No, we changed the line because of the line. Changes the cursor. So line is minus one again. Okay, Now, if we If we press sorry when you write else here. So if something but see is pressed something different than see we whoa, change the line to line plus one lying plus one. Because remember, every time you press any a number or something, who wouldn't jump one forward to make sure that we don't write the number one another number number? So we got them. Um, the set cursor lying zero zero is for the top off the display. One will be the bottom off the multi display. You can try it out and a line is the the line, the horizontal part where we print the did it on. So we changed the line two plus one Each time we press ah number. So if you press one to press another number again So that's that's a press one And then we pressed to Then it would write the one in the beginning in the first part off the LCD display Jumped one forward and right to so we want to make sure that the two dozen is not on top of the one. I hope that makes sense. Okay. And minus one. The causes. It starts at zero. Um, we have plus one here. So each time press a key, this plus one. So we have a minus one plus 10 Andi. So the first time it will start at zero on. And, um then it changes line two plus one. So have zero. And if we press another key again, it will write the number, not on zeros. It will write it on one. And if you present again, it will write it not on one will write it on to. So every time we have a different spots where where we print the number on kind of check, It's Oh, liquid Crystal does not name a time. That's where oh, we conclude that the wrong library. We included liquid crystal. We included liquid crystal, but we need liquid crystal ice. Coursey Sorry. So, uh, believe that now include library liquid crystal ice core. See, that was just a test. Check it again. No Syke researcher was not declared in this go. Well, there was also a test. We need the name off the LCD display before of instruction. Thing we get. Yep. The works done uploading everything works? Sure. Oh, okay. I think you can see it if we press something. I think you can see the one compress something again. That it will jump one forward. Linus line plus one. We pressed something again. So then it will jump again. One forward coastline and slam plus one on salon could change. There we go. Everything works Now If we press see, everything is being leader because on we have Al city the clear If we press see And now if we press something again. It will serve from the beginning. Yep. Starts so I can show you. This one is, um, the line. The horizontal line. So that's the first. If we if you If you think about this set cursor command, this is the line. And this is the top or bottom. So if the second the second number, if you say it zero it will use the top line. And if you say one, it will use the bottom line. Hope that makes sense. All right. I hope you understood the, um, coat on. See in the next video. 28. Project: clapping Fan; connecting: welcome back to the course of already. Know, I hope you're doing great in this video. We will program a fan, Um, that is controlled by the sound center. And if you clap or making noise, that will go on. So if it's if you were watching this course that summer right now, this is gonna be awesome. Okay, so maybe you've noticed that it's really annoying to have the wires connecting on the battery to the motor driver. So take off the tape, Andi and stab, we'll use that. It looks like really slipped. Looks like that. So this was connected here. You probably have that in your kiss. Well, you can just cut that off in the the end. Or did that? So cut that off. Put that away. We don't need that. And then we need to, um, cut off the isolator around the metal. So scissors, something or knife to cut off. Cut it off. I'll just conduct my camera. Okay. Um no, it take its on, and that's use a knife or whatever. Make sure you don't call your finger, and then what we do, I'm gonna do without here. That's easier. I just got it all until we conceive a medal. Okay, so it looks like this. You conceive a muzzle a little, and then you just say kids on and use of the metal, Hold it. Cut the rest off like this don't cut off the metal. And now we have the perfect tools to connect the battery through the motor driver. Okay, so the whole thing looks like this. Okay, Connected to your battery. And then we have these two ends on. Right now, we have least two wires, the ground wire and the five volts at the nine Volts. Aware which we used to come back to the battery. But now we wanna I'm on screw itch on. Connect this to the motor driver. Clam. We're perfectly fine. That's Oh, that was notes enough. So and they're a gun. Close. It called at this time a little harder. There we go that you're doing, and now we have the other ground wire to meet you. I'm blocked from the motor driver. Make sure you don't unplug the ari. No ground. Okay? No. As we connect this wire to the motor driver, you will see the power led off the motor driver go on. And also, if the Gardena scar, maybe a little higher, okay? And no close, it's it's it's not very. Take away the Are you in a ground for one seconds? That like like Reno ground? Um, closed again? I think that will work better or nod. Okay, that's a little tricky. Try that last time. Case of the looks pretty good on. That's much easier than connecting battery to the motor driver with the wires. That's a little more stable. Now we needs to connect the sun sensor. You already know. Oh, way have sown censure, perhaps. Okay, we don't need the lopping off the sound center. We have the ground and the five volts kill us. Connect Dance five volts on the grounds and you can see the sound turns or allergies. We're already on now. Which Nida Vigil pin these zero. Let's connect that to digital pin for Oh, my goodness. We're good to go 29. Project: clapping Fan; programming: okay. If we take the our old coat, I can just make some adjustments on at the song sensor so we can control the pen with the song center. So we need the pin that the additional pin off the song center make an imager Sound sensor pin is him for? I think, Yes, that is no other manager. Um sound sensor stage, The value we get from the sound sensor It was which to avoid loop the sound sensor State IHS Digital Read our sound sensor can. No. If the sound sensor stage is one, we want to run the fan. So if we clap or something whether we want to run the fan And if we clap again, we won the pound to turn off. Well, how do we do that? If sound sound sensor stage is one We don't need the analog, right? Right now they just all right, plus hello. Digital rights minus also low. What what we could do? We could make them both high on the mortar would not turn. So we need to have one high to make sure the mortar the DC Motor is turning. And if both are the same than the motors not turning. But when we actually happened to code here, it doesn't really help us because, um if sound sense from sorry if some sensor state is one it will. It will not turn the more will not turn and if it's one, it will turn. So that does not make any sense. Let's create another variable of Boolean. Remember, bullion can be true or false. Bullion is on is false So on the bullion is on We have that variable to keep track off the state off the off the song sensor or no, no sound sensor off the motor So if the mortar is turning is on its truth And if the motor is no turning is on his false So that's we upload the coach this honest false because the mortars no turning the more will start turning if we clap or make a sound Okay, So if the sound center state is one and is on IHS Falls you wanna turn the the mortar Onley if his own ISF also if mortar is not turning and we made a sound so if you made who makes sound it will switch to one So if we made a sound and the mortar is currently not turning We wanna turn or rotate the motor Well, if the sound sensor one if the song sensor state is one So if we make no noise Andi is on is true So if you made it sound on the mortar is turning right now when I turned off the motor Only if the mortar is turning on If the war is not turning we wanna turn it what we're gonna do? No. First of all this one iss else if because if this is not true, it will do that. Um, if we don't write that else, it might confuse the Gardena So but also costs were checking the state off the sound well, so I sound all right. Some sensor pin sound sensor then inputs on We have to change the Boolean variable. We're not changing it right now, so it will always stay falls If we leave it like that on it will just always If we clap once, it will always say on So when you change that so if we made a sound it will go on and we actually want to set the is on variable Too true, because, um, it's on right now. So we have a truth after the part when we turn it on Andi, if we turn it off, we, of course want to say that is on is false because the more is not turning band. It's false. Okay, So if Onley both conditions are true, this will around the coach will execute. Okay, so if we did not clap, it will check if it will check this section. But if we didn't clap Sorry we didn't make a sound. It will also not run this section because, um, we need Teoh to make a sound to make one off these conditions. So if we made a sound on the mortars not turning well turned on and who made a sound and more is turning will turn it off, Cal, it's Checketts on. Upload it. Okay. I think that looks pretty good. Show that to you. Okay, so I made a small adjustment. I put the fan or the motor on top of my water bottle. Um, yeah, I think that looks a little better. Okay, so if we're making a sound like that, it will go on if it does not go on. You have to play a little with the potential ometer on the solemn center. Yeah. If we make sone again, it will go off eventually. Yeah. Do you turned the potential honor? A little should get better. There we go. So I think that was a really nice project. I hope you figured out and it's working for you on See you in the next video. 30. decode the controller: how the Internet works is actually very simple. If you have the controller on a TV, it's not the best to be. But for now, it's OK. If you press a button on the controller like that, it will send a pulse to the TV or to the receiver, and each button has a different pause. And with the arena, we want to encode or decode the pools or the code. Each button has a different coat that is sent to the receiver, and we want to decode the coach so we can use the code in order to control the already. Know how. You can check if you can basically use any infrared controller to control already. You know the receiver looks like that's I open it. So that's the receiver. Here we go. Okay, so so it will send a pools from the controller to the receiver, and each button has a different pools. So okay, if you can use in control or any infrared controller to control that, are you know how you can check if it's infrared controller? The, um, the cameras off your phone or tablet can usually, um, sec. If it is on infrared if you if you press a button, you can see a live. So you know that the infrared signal sent. So how you do that if you hold it right into the camp, I promise you connecting the infrared receiver is super easy because we only need to connect the receiver. Nothing else. We don't need to connect the and infrared transmitter the controller, because it will sense pulses on. We just want to receive and decode the policies so we only need the receiver. So let's take already Brad board. Andi, the infrared sensor looks like that has three pence, so it's super easy to connect. We have one gram pin, which is G. We have won five world spin, which is our on. We have one pin that we need to connect to the digital pins. Which is why. Okay, Put that into your bread board. You have ground. We have five boards in the middle. Andi, don't forget our pixel pin on the rights. Okay. Connect ground to ground bolts. Too far holds on the digital pin. That's kind of get your digital pin six. All right for that super easy. And now we're ready to program it. Okay, so first let's include our library for the infrared sensor. Include library if you don't have the library. Goto Um, don't you hopes go to include library and done. Manage libraries so you can dunk the library. The library is called. I are remote infrared remote on a scroll down until you can see it on. Select the most recent version. Then you can install it. So we include the library, or that's ir emotion low. Okay, I think we need only one. I think we need only this one. I don't know what this is about. Okay, Now we need a pin. Um, the pin from the receiver. So we const int const means only that it won't change on We call it a receiver in on its a pin six. No, we have to define our from all receiver so ir but a receiver Oh, call. It's i r s Oversight s a p capital air. Um, let's call it. Yeah, um, yeah, I receiver skids on. And now the receiver pin. Okay. On the decode results. We need that, Teoh. When you neither to make sure that will be the value we get when we press a pin. A button on the controller on it will send the poles to the receiver, and that will be a result. So tika results. Okay, Now you're ready to go, boy. Set up. Start the serial major because we want Oh, sweet. When d coach are the polls is or the coach from the controller because they each have a different code or different pools. I want to decode it, to use the coach to get a code from the controller, which we receive on the through the receiver we want to use that cold code to control are you know? So it's start the serial manager 9600. No, we want end able the receiver. So I arrest you for and Abel, I think it's I all right. Um okay, So money unable the seamer. Also, if we receive something you want to show or print of the coach on the serial monitor, So if fire see todo decodes, deacon results. So if we receive something one of printed if we receive something print on the serial monitor. So if received, received the polls or the coach off the button from the controller print that on the serial manager. Andi. Um, cereal, serial print line. Um, press. We're assaults value. Okay. On. And after we printed on the serial monitor. You want to continue receiving, um, receiving the coach or pulses? So I for sihf for S u I receive us up here hard. Enable the receiver if we receive something that print on the serial later to continue receiving. Um, if we receive something, I hope that makes sense. Let's check the coat. Uh huh. That looks good. Connect. You already knows. You will be seat. Andi, upload the codes. Yeah, if we go to the show on one. Sure. Press something. Okay. So if I press a button, you can see if I press hopes are a press the same button over and over again, it's will, um right the same, um, the same number. Okay. By this one, we go that maybe this button will Myers. So they each button has a coach or a pulse there is being sent to the receiver on with the coat that we just uploaded to already. Know we can print the coach from the arm controller on the serial monitor so we can use the coach to, let's say, turn on led so we can write down. If you press this button, its power on we can write down the coach. Use the coach to, um to, let's say Troy Normal led or something Butts would get a huge Um, we get many numbers are now. We don't want to have so many numbers. We will convert them to hacks, a decimal so it will print Hexi decimal on the ceremony, or now so X should. Let's check if it will. But we could also use the numbers, but it's a little easier with hexane decimal. Let's check if I press the button that it will printed and accidents. Immel sometimes gets a wrong, um, wrong coat. You can say it's no. The receiver is not perfect. Budge. It's pretty good. So if you change, if you press on a different button, it will send a different coat on. And that's how it works. Okay, so, um, let's write down some hacks. A dismal numbers to make sure that we can use the melody or something to control with a controller. Take one. Yeah. Um, okay, let's let's say we want to use that button Teoh, turn on or turn off analogy. We need to, um, to write down the coach that is being sent. If we press that button, I think that makes sense. So if you compressed multiple times to make sure that is the right coat, maybe I could have a wrong coach so like, but it's always F F 25 deeds. That's what we write down. If f a 25 D um, let's say you want to use another button to turn off the led Well, we could use the same one that would work. But let's let's use the stop button, which is here. I'm like I said, you could use any, um, controller you want so you can use the one than for Ecuador off your TV on. There will be totally fine again. You could check it if you hold it into into your camera. There's more form smartphone camera, and you will probably be able to see the infrared lights can see the infrared light with our eyes. So okay, if we press that bottom, it will say F f B 21 D. Okay, so effort a 25 D is on. So if you press that button? Melody will go on if you press F f b 21 D L d l ve will go off the lady. Sorry. Okay, um, let's move on to the next video where we connected. Program the allergy Control. What the controller? 31. control a LED with the Infrared Sensor: that's on led tower circuits. Put it here. Then you will use 220 homes. So resistor Okay, tonight that ground. Andi, the energy we connect to Digital pin eight. Okay, so a node is connected to just open age. And the, um, infrared receiver is connected to digital pain. Six. Okay, we rode down the two coats from the buttons off the controller. So if out pressed that button, I'll get a certain court in a press of that button. It'll get another coat. Each button had a different coach because it's a different. They sent each button standard different polls. And in the last view, we were able to end coat or decode the coach controller. And now we want to use the coach off the button off the controller to turn on or turn up on allergy. So we'll need to change the coach from the last time. A little bit. We need the library again. Include library. Why are Mote? We only need the this one. No, we have in nature again, Constance, because the injury doesn't change. So const Imager is Let's call it a receiver. Seaver penned. She's connected to pin six. No, we have another nature for the allergy. L e d 10 IHS him eight, I think. Yes. So, eight. Now we have to Hi for C gross. Here we go. Um, now the receiver pain l A reid receiver? No, the D coach for assaults. So if we get a result to be saved under assaults, Andi know we can jump. Just avoid set up knows that. Okay, start the serial monitor. Andi enable that receiver, so enable I Okay, also pin modes the allergy. Pen output. Okay. Now, if we received, they will receive value. Chris, for a soul. Okay. You wanna if you receive a value. Oh, no, I didn't get it. Came if you received If we receive a value, we wanna check if the value is either this button or this button. If it's that button, we wanna turn on led and of it. This button. Wanna turn off the allergy? We know the code off off the budgets, so we will use a function called switch, which, um, then we have race Soltz. Well, you and it's Yep. On that function we write, it's it's been it works like if if else what? We already know, it's pretty much the same, but, um yeah. So, case, in case we have the well, first hacks a decimal number. So the no, we have to write the number that we notice in the previous video for the button where this buttons were pressed, that this budget, the allergy should go on. So, case Oh, we got we got a value. So this button is the red button, this f A to five D. And if you press that bottom, we want that led to go on. You will have a different code for that button because you don't have the same, um, controller, So f a Oh, don't forget we need to put on Oh, I mean zero x before the coat, so f a 25 d. So that's the case. Um, we wanna turn on the led right led ecology, been I And then we have another function which is called break. That's just to stop, um, the to stop the fashion. So if if it's if we if the case is that so if we press the button, the red button, that will be the case. So we get that hacks a decimal number Andi. It will around the coat between break and K. So it we're on this. So turn on led. Okay, let's check it. Okay. I made a little mistake here. We have two rides. We have to run this way. Now, which of work? Check it. Okay, Now it's working. Let's that the other. But, um, so in case, um, case the other one, which is so the other coat from button just f f b to one d. So that's the case. Digital, right, Helly? Deep in lo. So if you press the other button one, turn off allergy break before we uploaded. When our assume. I'm sorry. Um, yeah, um Or assume so it will wait for the next, um, code we get from the infrared sensor. Okay, now we can upload it. Never know float it. Uh, so but something. Here we go. Okay, that works perfectly. Okay, so we have the led right here. Andi, the controller. And if I pressed that bottom, the allergy will go on. There we go. And if I pressed that button, the allergy will go off 32. introduction to Ultrasonic: Welcome back to the course of our Dina. In this section we will measure the speed of sound with an ultrasonic sensor. Lets get started. 33. connecting the Ultrasonic Sensor: Okay. I want you to get your heart, you know, and your songs. Mascot Islamic center. It looks like that, uh, what? We wanted you We'll use the Brad board. Andi, plug in the ultrasonic sensor. And you want to make sure that the front of the ultrasonic sensor, which is here, um, iss on the same side, Um, like the and of the Brad port on the same, um, distance. So if it's like that, its origin far because you can see the front off. The ultrasonic sensor should be on on the front off the bread board. What's that? Okay, so I think that looks pretty good right now we connect the ultrasonic sensors to arlena we have we have of the ground. Then we have the echo, the trigger on a busy C, which is like bolt's. Um, yeah, how that thing works. If you have an object right here, it will send over sonic sound wave. Andi, It can measure the time how long it takes to get the ultrasonic wave to the object in back . Okay, We want connected to the arena. So the ground goes to ground authority on the BCC. Just five volts then we have the trigger. We can connect that to Penn 13 and the echo pin. No echo pin can connect a pin which still pin. Okay, so we have trigger pin. Connect to the digital pin 13 on the echo pin to the visual pin. 10 ground to grounds on visas. He do five volts. Also, when you get an object, it doesn't really matter. One slow. It has a flat surface. Andi, I want to you to place the object seven centimeters away from the ultrasonic sensor. So we have the ultrasonic sensor here. Andi is parallel to the bread board. Take the object and place it seven centimetres away from ultrasonic sensor. So we have seven centimeters distance between the older sonic and the object. All right, we're just programming. 34. understanding what to program : all right. Before we start programming, we need to know Holy gonna program it. And what we want to know is the speed of sound and what we have R is the distance. So the distance between the object and the other sonic sensor our seven centimeters. So the ultrasonic center is seven centimeters away from the object and all that speed is is distance divided by time. So if you say car is driving 30 kilometers per hour, it's actually kilometers divided by our okay, What we have is the distance. So the distances seven centimeters divided by the time that we get from the sonic sensor at the time will be in microseconds. And we don't know the time yet, so we have to figure out the time. Okay, Um, the ultrasonic waves from the from the ultrasonic center will go to the object and them back to the ultrasonic center, so it will measure the time it took the ultrasonic wave to get to the object and back to the ultrasonic sensor. But we the only thing we want to know is the time off the ultrasonic wave from the ultrasonic sensor to the object. So we have the time divided by two so divided by two on the 7 70 meters on when we calculate that Well, So if we divide seven centimeters by the microseconds from from the ultrasonic sensor to the object, we will get, um, Centimeters. Well, one centimeter per, um, per micro seconds. That's what we will get a za result. That's what one you know. Okay, That's what we're looking for. Now we're ready to start programming. 35. programming the Ultrasonic Sensor: all right. As usual, we need a few imagers, no imagers, a few variables to control the ultrasonic sensor. Okay, so we have imager for the trigger pin. That's that controls when the ultrasonic wave is stand out from the ultrasonic sensor. So the trigger is 13. The pin and we have the EC open, which is, um, digital pin 10. Okay, once we need to know is the time on, we will use afloat because it will be a decimal number. It will be in microseconds, so it will definitely be in decimal variable, so float time. And, um, we have the distance. So we the distance of seven centimeters, so in distance is seven. Okay. What we want to dio is to print the speech or the time first. Well, we'll measure the time first in them. Make the step to the speed. We need some more population. If we want toe, calculate the speech off the sound. So, um, serial begin 1006 100 and pin mode the trigger. Remember, the trigger is the pin that we control to send descent or a sonic wave. So that's one. This one is output because we controlled it on the pin echo is inputs because, um, that's the pin where we received the time, actually, microseconds. Okay, You wanna we want to turn off the trigger pin first. So digital, right? Trigger lo. So it's it does not send a signal in the beginning, and we will wait five milli seconds, and then we want to do is you want to turn on the trigger pin so high. So as we turn on the trigger, it will stand out the ultrasonic wave on. We will let it send out the waste for 10 milliseconds. That should be enough. I was gonna make a comment. Don't send, uh, signal where? Send by for 10. Four turn Melly seconds, and then we turn it back off again. So digital, right? Trigger love. And immediately as we turn it off, we want to measure how long it takes the sound wave to get to the object and back to the ultrasonic sell incense tree. So the time it is, uh, pulls in that co. Hi. So now we have the time. That's a new command. I think we didn't have that before. Yes. So what this does it measures the time off off the ultrasonic wave to get to the object on back to the ultrasonic sensor. That's what this is for. And we will save the time in the variable time. Um, we have to be careful because the the time we get from the ultrasonic center is not in seconds or milliseconds. It's in microseconds. So the variable time will be in microseconds on not in mili seconds, because as we delay something this always in milliseconds But as we save of the time, offered a sonic wave, it will be in microseconds. All right, now who wanted cereal print the time? Okay. Groups okay. Will not oppose because I didn't connect the Arduino. Yeah, let's check it first. Okay, We didn't make a mistake. Will use the object on place at seven centimeters away from the ultrasonic sensor. Okay, Now we upload the coat again. Go Well, Bloody Norrena. Yeah, it's float. Yeah, I told you, it's the time has flown because it's a decimal number. Yeah, okay. If we go on the serial monitor, we can actually see the time off the ultrasonic wave to go to the object back to ultrasonic sensor. So show you not but It's not very interesting because it doesn't really do anything just off involved Sonic Sensor because we cannot. Here the sound ultrasonic sound don't super bright. Okay, however, Um, think you can see the ultrasonic sensor and the object on their away. The distance between them is seven centimeters. We measure the time that the ultrasonic wave needs from the ultrasonic sensor to the object and by colder sonic sensor. But we don't want the one to have the time to the ultrasonic sensor to the object and back to ultrasonic century. We only want to have the time to the object, so we need to divide the time by two. So time is actually the time we get from the older sonic sensor. That's the time to the object and back the ultrasonic sensor. And now we divide that by two. So that's a number we divided by two and save it in the variable time. Let's upload it. If we take a look at the serial monitor, we can see before we uploaded a new coat. Itwas like four hundreds microseconds or fault for on 32 or something, and now it's 216 or 215 microseconds. That's the time the ultrasonic wave needs, from gorgeous, a ultrasonic sensor to the object. And previously we had the time that the just ultrasonic wave needs from the ultrasonic sensor to the object on back. So now we have the right time on No, we need to add another variable. Another flows, which is speed okay, and speed is the distance. As I told you, the distance divided by um, divided by the time. So that's a five kilometers per hour is five kilometers divided by one hour, and now we have the distance, which is seven centimeters. So because our old Islamic center on the object are seven centimeters away from each other , we have the variable seven centimeters divided by the time in microseconds. Okay, so the time is the time from the edges off the time off, the ultrasonic wave from the ultrasonic sensor to the object. That's the time in light and microseconds. So we have distance divided by time. That's what Um, that's what speed is. Distance divided by time. So it will calculate that on divide distance by time and we will get centimetres per microseconds. That's uploaded. Oh, well, we will not get that because we're still printing the time on the serial monitor. But now we want to print the speed. Okay, there we go. Now we have 0.3 centimeters per microsecond, which is a really fast, um, well, later, we will calculate thus two kilometers per hour. And then I think you will have a better feeling how fast that is. Okay, so we just had 0.3 um, centimeter spire here microseconds on. If we go on on browser hopes. Andi with search for, let's say, uh, speed off sound and centimetres per microsecond. You will see that, um, one centimeter for a microsecond is 0.3 that we just got from this year old monitor, so it's 0.343 centimeters per microsecond. All right, that's the speech off sound onto the next video. We'll calculate, um, will convert that speed into kilometers per hour. 36. converting cm/microsecond to km/h: All right. How do we convert the 0.3 centimeters per microsecond to, um, kilometers per hour? Okay. All right. Converting on. We have zero Poland zero through a senti mirrors per microsecond for one microsecond. Well, before we converted two hours. Let's converted two seconds and then minutes. Inventor hours. That's a little bit easier. So how many microseconds are? Um, one second? One million microseconds. So if we multiply this by one million and this by one million, which we have to do in order to get on one second, we multiplied the microseconds by one million. And now we have to multiply the 0.3 centimeter spending. One million. What? It? 23456 we go, aren't we got 30,000 centimeters. So now we have 30,000 centimeters per second, which is the same as 0.3 centimeters for one microsecond. That's exactly the same speed. Now what we want to do is to convert from second to minute. So, um, one minute are 60 seconds. So we multiply that by 60 and then we get one minutes on this time. 60 iss things. 1,800,000. Want to six? Yes. So we have one million eight hundreds. 1000 um, centimeters per minute. That's the speed of sound. That's everything. On here is the same speed. So 1,800,000 centimeters per one minute are 0.3 sending the respondent for one microsecond . That's the same speed. We're just converting the speed. But it will always say the same speed. And now we have 1,800,000 centimeters on if you want to convert it to meters, so we get one million. It's 100 1000 70 meters for one minutes and 2,600,000 centimeters are well one meters 100 centimeters. So we divide the 1,800,000 centimeters by 100. So 1,000,800 1000 by 100. And now we have 18,000 meters per men. That's everyone. Go on DNA now. So we have one minute for one minute. We have 18,000 meters still the same speed. But I want to go from minute to our so kilometers per hour. So we, um one hour is 60 minutes, so we multiply it by 60. So we got our and then 18,000 meters 18,000 meters times 60 which is one million and 80 1000. Don't forget the unit. Um we still have meters when we have meters per hour. So one million, 80,000 meters per hour. It's the speed of sound now because you wanna kilometers per hour. Well, how many meters are one kilometer? 1000 meters air one kilometer. So we have to divide that number by 1000 in order to get the kilometers So 1,000,080 Just like that, Um divided by 1000 IHS 1080. So we have 1080 kilometers. Care for our or 1000 Reggie. All right. That's, um the speed of sound. All of that is the speed of sound. Just in another unity, we have here kilometers per hour than we have meters per hour, meters per minutes, centimeters per minute on so on. Right. So you can go in your browser and search for the speed off sound and it will be probably a little different. Won't be the exact same number we got because yeah, we have. I have a different temperature in this room. So it also depends on the temperature. Ho fost the sound can travel. Yeah, so if you search online, you'll find a slightly different result, but that should be pretty close. 37. measuring distance with the Ultrasonic Sensor: Let's take a look. What we're gonna do. This video in the last video will learn. How do you measure the speed of sound on? Well, the speeders 0.3 centimeters Per, uh, micro second for one microsecond. Um, that's what we figured out last video. If you didn't watch it, please watch. That will be a lot easier. Um, well, no, we want to measure the distance with a ultrasonic sensor. So, um, how we're gonna do that? We know the speed of sound. ISS 0.30 point 03 centimeters per microsecond. Um, well, what we can measure with older sonic sensor is not the distance, but what? We can calculate the distance. But what we can measure is the time with arena. So the time in microseconds. So let's say we have 216 microseconds, so that's the time divided by two. So it's the sound way from the ultrasonic sensor to the object. Usually we have a sound wave from the ultrasonic sensor to the object went back to the ultrasonic sensor. So we have two divided by two on If we divided by two. We have the time off the sound wave from the ultrasonic sensor to the object. So that's our time. It's just an example that say that it took 260 microseconds um, the wave to get from the ultrasonic center to the object. Onda. We know the speed, so it's around. Zero Poland zero three, um, three to say per microsecond. So that's the time. The speed we figured out in the last media on. We simply divide the time it took the wave from to get from the ultrasonic sensor to the object we multiply. Um, the time with the speed. So if you take a look at that, we have, um sorry. Forgot the centimeters here. If we multiply it. We have 216 micro seconds times 0.32 centimeters divided by one my curl set. Can't There we go. Well, we have microseconds down here on. We have microseconds up here so we can just simply the lead that because my second developed by microsecond, I can't believe that. And now we have 216 times 0.32 centimeters is let's calculated 216 times 0.32 Is it will be our own seven centimeters. Six point line. Okay, So why I knew you. Because where new? It's around seven centimeters in the last video. We if you remember in the last video, we had the distance seven centimeters. And we measured the time. It took the wave from the, um from the ultrasonic sensor to the object, and it took it 216 microseconds. So, um, yeah, probably the object waas Nor exactly seven centimeters, um, away from the ultrasonic center on. Maybe it was only 6.9 centimeters away. So yeah, that's why it is not exactly seven centimeters. Yes. All right. Okay. Lets go a hat on. Try to measure the distance with the ultrasonic center. Um, we need the pins off ultrasonic sensor. So we have the trigger. The gun triggered freakier, which is some pin 13. We have the echo, which isn't pin 10 in turn, I think. Is this Yes. 10. 13. Here we go that we have float for, um, the time Andi flows for the distance. Distance. Okay, on. I think we're pretty goods for the variables. Start the serial murderer Cereal began. 9600. No, we have pin molds trigger output because we control that pin. We don't get a value. We don't receive a value. We decide when we sent that there was a sort of sonic sound wave. Then we have the echo, which is in port. Okay. And put phone. Okay. No, I want to make first. You wanna turn off the trigger and cast its turn on so trigger. Hello? Then we make a small delay five milliseconds on. Then we turned on the the trigger to send to Sander some wave, and we wait 10 milli seconds, so it will send the way for 10 million seconds, and then we turn it off again. Digital. Right? Um, trigger No. Andi. Okay, now we have the time. Time is, um, pulls in, I think. Uh, hi. So we measure the time. Okay, So that's how far we got in the previous video. Now we got we we could calculate the the time, actually ordered the speech a little further so But now the thought is that we need to calculate the distance. So this dance You know what you will make distance along long. It's just another variable can save mawr. It has more digits. So, um, distance is, um, time. What do we do that time divided by two. Okay, so that's the time we get. That's the time the sound wave needs from the ultrasonic sensor to the object Not back because we divided by two. So we have the only the way from the ultrasonic center to the object on. And well, then we had the the speed off the sound, which is 0.3 um, centimetres divided by one microsecond because because, um, we don't divide it by one. It's always the same number, so it doesn't change. So we don't need we don't extra need the divided by one microsecond. So we're just gonna do the time times, um, distance that makes sense. So I mean, I mean, the speech, the speech, the distance off the speed. So speed is distance divided by time, and we take the speed. I mean, the distance off the speed on. Um um we multiply it by the time and divided by the microseconds, but we need we don't need actually to the line by by the microseconds, because the microseconds is always one. So now that the distance off the speed. Which just zero point zero 342 No. 3432 Um, that's very, um, that's super has a lot decimal number, so it's very accurate we own in the in the video where we try to figure out the speech. We only had 0.3 Um, is your 0.3 centimeters. But if you search online, you can see that's actually 0.3432 and so on. So that's a little more accurate. Okay, so then we have the distance. So, um yeah, that that will be the distance that we that we tried to figure out. That's the distance. If so, you can move an object. How far? How far you, however far you want to move it away, And then you can put your order Islamic center in front of the object and it will measure the distance. All right, But if the distance is higher, then let's say five hundreds or, um, where is it? Oh, my goodness. There we go. Or I was trying to find these two sticks. So, or or the distance is is smaller or smaller or equal to zero Um, because if it's smaller or smaller or equal to zero, it's not very accurate. So it can. The order Sonic Center cannot measure distance that is higher than five meters, which is 500 centimeters. So 500 here or if it's smaller than zero, you cannot measure negative number, so we have. So if if it's higher than 500 or smaller or equal to zero, we will write cereal, serial print lying. Um, nothing did tech touch. Make sure you have the quotation marks. Think by now you know how to use the serial print command. So if we don't have the quotation marks that will think that this variable but it's not so , um so yeah, if it's higher than 500 centimeters or smaller than zero or equal to zero, will say that there is nothing detected Andi else else well else, say or Prince that print the distance on the serial monitor source cereal print line. Um, the distance. No. First he rides there stands to object, so print we don't want a printed in new lying printed on the same line. So distance to object. Make sure you have space right here, so If we ride cereal, the trend distance, it will leave a little space here and then right the distance, which is a variable. So without the quotation marks and now we wanna, um, change the line so we won't write anything. That's a little trick to jump into the next line. Who? Bride thes two commands on the same line. Then we jump one line and write them again. That's our first. Yes. Let's make a small deal way. Se delay 500 for far milliseconds. Sore 0.5 seconds. So it will always wait half a second and then measure the new distance. Okay, um, but we have a comma here. It has to be dark, because if it's a comma, the arena doesn't know what to do with it. It has to be points. Okay, let's upload it to already know. Let's look at it. Here we go. So it's tracking my arm right now. I take it away. Hopes. Sorry. Do that. Okay. If I put my arm away, okay. I guess it can see my books or something. Whatever. Um, if you put the object that we used Teoh to measure the speed of the sound began seven centimeters away from the cellar. Ultrasonic sensor. You will see that that it will say that it is seven centimeters away on if you put it for the way it will say 89 10 11 12 13 14 15 16 A. Whatever. All right. So, yeah, if you want to see that. Oh, so I have the mostly. There's the ultrasonic sensor on the object IHS here. So if I take the object, you can see it is getting closer on the serial monitor numbers. 5th 14 13 12 11 10 Okay, if if I place it around here, it will say seven centimeters. Yes. Um and if I move it back, you can see cause 13 14 15 16 17 18 1920. 30 40 On. If you take this ultrasonic center on, let's say move it up. Yeah, well, if the distance to the next object iss further than five meters were 500 centimeters away, it was It will say that nothing is to take it because you can detect anything over five meters. Yeah,