this is an immersive Hands-On Arduino course for beginners throughout this course you'll dive deep into the world of microcontrollers learning how to create modify and optimize Arduino projects from scratch by the end you'll have the skills and confidence to bring your innovative ideas to life using the power and versatility of Arduino hello my name is Matthew and I'm going to be your instructor for this Ado course anybody can follow along as this course is beginner friendly so you don't need have any prior knowledge in programming and electronics this course comes in full package so everything you're going to need to learn about Arduino is fully provided here personally when I was learning about arino for the first time I was jumping from course to course as instructors to not teach me one aspect so to prevent this almost everything from Electronics programming and even physics concepts are going to be fully included in this video one final thing when I said anyone can follow along I mean it even the ones who don't have a phys physical Arduino kid I highly recommend that you get an Arduino kid as it is more engaging but I will also be using a physical Arduino to teach but if you don't have one don't worry I will show you how to follow along using a simulator with that in mind let's start our first section before even working on a physical arino the first problem that we run into is there are thousands upon thousands of arino kits and we do not know where which one to use to follow along in this course so in this course I'm going to be using an inland starter kit and an inland electronic parts pack I'm going to leave uh a link in the description of this video so you guys can check it out for yourselves okay so I'm going to be using an inland starter kit and Inland electronic parts pack but when it comes to uh these Inland starter kits they're only mostly or mostly they're available in what they're only available in the US so if you're outside of the US you can get yourself an elgo UNO super stared kit okay you're going to get yourself an e Lego Superstar kit with an LED Matrix so this kit does not have an LED a component named LED Matrix which is very important because I'm going to be using it in this video so you're going to get yourself an e- Lego Super Starter Kit and then you're going to get it separately you're going to get an a display matx okay so an LED Matrix okay so one final thing is if let's say you already have an arbino kit and you want to know all the components that I'm going to be using in this video I'm going to State them on the screen right now so you can again cross check on your Arduino kit and on the screen right now if you have the kit if you have the components that are required if you don't you can again separately Google them and try to buy them from Amazon and different stores so with that in mind let's move to the next section okay so for those of you who don't have a physical artbo and want to follow along using a digital artbo I'm going to show you how to do that so what you're going to need to do is go to your browser and then go to Tinker Cad and then touch the first link it's going to be tinkercad.com let me just zoom in so you can see it there we go and then open it okay so for those of you are joining or using Tinker cat for the first time it's going to be asking you to sign up or log in so we going to do that I already use Tinker cat so I'm just going to log in directly to my account afterwards all you need to do is go to your designs create one and then go to Circuit it it should be loading and once it's done loading all you need to do is use this tab for components so you're going to be searching for the components that you need right right here and then tapping them and adding them when you do and there is a Cod section right here so basically you can write code to your Arduino and then you can start the simulation that's all you need to do to follow along using a digital simulator so with that in mind let's actually work on our first Arduino project for our first project we're going to build a simple circuit the lights up an LED let me turn off the light for you guys so you guys can actually see a quite better okay so we're going to check the components that make up the circuit so we're going to check the breadboard we have here the resistor we have here and also the LED so we're going to check them out separately before assembling them into this one project so see you in the next section before actually talking about bbbs let's say I want to connect my Arduino and build a simple circuit okay I have my Arduino right here and before turning it on I'm going to connect the pin let's say right here randomly again say I want to connect it I'm struggling a bit right now to hold it okay I did hold it it's a bit of a struggle let's say I connect uh connect it to here it's not even comfortable let's I connect it to here okay then let's say I I'm going to use a third wire I'm going to be building a complex circuit in this case my hands are preoccupied so I cannot really build u a more complex circuit as again I cannot put a third wire so this is where breadboards come in and actually solve the problem not only that too but also if I turn on the Arduino and I as I said again connected to the pins I'm going to be Zapped I don't want that to happen so now let me bring my deboard right here so backboards come in different sizes and different shapes so there's a smaller one and this is the bigger one I'm going to be using the bigger one to explain what are breadboards and how they work so if I go real close up here let me just point my light towards this so you can see it okay so if I go close really close actually let me zoom in I zoom in right now and if you check this out is you see wires that run horizontally let me again okay there we go we can see it right now wires that go horizontally right here all of that you can see that there are wires that are going horizontally okay the same goes for this one too again bring it up close TOS the light okay there we go they go horizontally if you check them right here if you look at these two wires right now they go vertically okay the one that are found on the edges they go vertically the same with this one that is found on this Edge goes vertically okay so now let me zoom out right now this is good okay so it only goes horizontally so a up to e are connected okay so they are connected horizontally connected horizontally connected horizontally connected horizontally and connected horizontally it keeps going on all the way to the bottom okay this same goes from F G H I J they are connected horizontally horizontally horizontally horizontally and all the way to the bottom okay so one important thing is e and f are not connected okay there's a gap between them as you can see right here there's a big gap between E and F so one thing is e and f are not connected okay so a up to e are connected on their own but a up to e are not connected to f up to J okay so they're not connected a up to e is not connected to what f g i j basically so they're not connected to each other because as I said again there's this big gap okay put that in mind when you look at the ones that are found on the edge as I said again if you look at the wires again they're connected vertically so all the way from the bottom to the top they're connected vertically okay from the top to the bottom they're connected vertically so it goes like this so go like this and you have to go ver vertically all the way okay all the way vertically they're connected the same goes for the the one that is found on the most Edge okay so these two that are found on the edge they're connected vertically all the way same goes for these ones so right now all I have to do to conduct electricity is uh bring my conducting wire right here put that right here and put this right here and if you again look up close you're connected because there in the same row so if I put this one right here let's see all the way to the bottom okay all the way to the bottom All the Way to the Top O okay they're connected okay they're connected the same goes for these ones too and these ones and these ones too okay so the same goes for this one they're connected again horizontally I just want to recap okay so let's say I want to check this like scientifically so I'm going to bring a device called a multimeter you guys do not need to have it but it's just again to check um okay so let me just bring that right here it's a bit of Tangled right here okay so let me just bring this the pins are big so it won't fit in the holes so what I'm going to be doing is using this conducting wires and just connecting them with the conducting wires pins okay so now if you look up close it's set in the mode of cont continuity okay this this basically means it's continuity and continuity checks if an electric current is going so for example let me turn this on we turn on the power and if I bring these two pins together it's it starts to make this beep sound and not only that too but also this red bulb lights up and so does the number change okay okay so with that in mind we can know that there's electrical continuity as I said again electrical continuity basically means that current can just flow okay so with that in mind let's say I bring one right here let me first go up close and show it to you guys so let me bring uh connecting wi to 20 let bring another connecting wire to 20 again connected horizontally perfectly horizontal let me just put that right here and let me bring these two pins and connect them with the wires can you hear that there is an omnious beep okay that means that hey current can flow okay with that in mind let me just connect this vertically all the way let me go the whole way okay vertically say I want to connect them just bring this pin right here connect that right here let me just bring this too and can you hear it there we go this basically means this hey a current can just flow through okay because they're connected right here they said vertically so with that in mind let's move to the next section where we're actually going to discuss about uh resistors so see you in the next one okay so in this section we're going to discuss about about resistors so what are resistors resistors are electrical components that are used to limit current this is going to be important because we don't want to damage other components due to current overflow okay so let's start from this simple diagram okay so right here we've got the positive terminal of the battery the longer side is the positive terminal as you can see here and the shorter side right here is the negative terminal so current always flows from the posit positive terminal to the negative terminal so it's going to f like this go through this resistance right here and then go through our LED lights up our LED then goes back to the negative terminal so I said again resistors are used to limit current why is this important so if we let's say let's forget about the resistance existing here for a moment so let's say we connect it directly directly to the current and we put our LED in this case we're going to fry our LED because we're we're going to be using too much current okay so we want to limit the amount of current that goes through because we don't want to damage our LED that's why we're going to be using resistors so right now we're going to use arms slow it's known as V equals to I * r v stands for Vol voltage which is measured in volts I stands for current which is measured in ampir and R stands for resistance which is measured in ohm this is OHM the symbol you see right here it's ohm oh okay so right here to actually even give you a better and a clear analogy let me bring my Arduino right here and let me bring this close close enough so that you guys can see the 5 V that 5V means that it's going to Output 5 volt okay so that's why I said 5 volt right here so let me just place it right here then current goes and then we have our resistor and by the way if you don't want to know how resistors look like they look like this moving the pack and let me show it to you guys they look like this sometimes you might find the yellow one but it's okay blue or yellow is the same thing okay so we have our resistance right here let me place that right here and we have our precious LED let me just place that right here so right here when it comes to LEDs they have a maximum limit of 20 milliamps so if you go over 20 milliamps what's going to basically happen is we're going to fry our LED so we don't want that to happen how do we prevent it we use this low so right here we have five volt that is going to be output by the Arduino so we're going to say 5 V is equals to this is 20 mamps is the maximum the recommended one is 10 to 15 milliamps okay it's 10 to 15 milliamps is recommended but this is like the this is like the full maximum so let's use 15 milliamps because we don't want to go over the recommended limit and we have our resistor right here okay so let's divide this this becomes 5 over 15 and we have Millie right here so it's going to betimes 10^ of 3 and we've got our ohm I said earlier it's measured in ohm so in this case it's going to be 0.3 continuous * 10 the^ of 3 okay ohm so R is going to basically be 333 ohms this does not mean we have to exactly give it 333 Ms but rather we should give it a range of let's say 300 to a 400 m range okay of resistance for this current not to obviously overflow and as I said again basically firey our LED we don't want that again to happen Okay so with that in mind how do we you know measure how much M resistance is so we're going to actually check it so let me bring there are two ways to actually do it the first one is we bring our resistor up close okay and what you need is a resistor color code you can Google it if you don't have it on your kid or you don't have an arino but this is just a resistor color code so right here I have it right here so let me start from the first line the first line is red and if you look close enough right here first line of red means two so let me bring my Sharpie right here let me write two down you got two now let's look my let's look at my second second band right here it's also red you can see it it's also red second band of red means two so we go two right here then I have my third one if you can see closely it's black so when we look at it right here when you look at the third one it's what it's zero okay okay then we have my fourth line my fourth line is also black so I go to the fourth one and it's a multiplier so this is basically how much I multiply two so in this case it's black so it's times 1 M okay so when you multiply it it's 220 amps if you look even close enough there's a fifth band right here that looks Brown this is just tolerance and we're not going to get into it because it's not really really important surrounding this level okay so okay with that in mind we have 220s of resistance so you guys can check your resistor by basically looking at the color codes okay there's also another way to actually do this so in this case we're going to go back to using multimeters so right here we have our handy multimeter let me just untangle it right now okay so let me bring back those that I had here that I calculated to be 220 right here so let's see if it's that's actually true if I want to be dead sure okay so let me just move this paper right here okay so let me turn it on and right here what I'm going to basically do is change it to the resistor mode as you can see there's arm right here so we're changing it to this resistor mode so if I go to 200 ohm right here it's going to detect a one it's going to detect uh 200 or less for example right now I have 220s that I calculated if I put it right here if I again connect it right here let me just connect it can you guys see it it says a0 222 let me change it to 200 amps right here if I go 200 amps it's not going to detect anything as you guys can see why is that so you might be asking me well it detects 200 amps or less okay it's not going to detect 200 that are above 200 amps it's going to detect 200 amps and less it's not going to detect something that is above 200 amps in this case this is 220 amps which is above 200 amps so it will not detect it so if I go to two kilo okay 2 kils right here and let me just connected right here now we get a signal of 2242 not exactly but we get 242 let me just bring my paper back okay so 2 42 242 and as you can see here it says kiloamps so we have to say kiloamps when we do the math this turns out to be 242s which obviously is not 220 amps directly but it's just very close to it so we can use our multimeter to again check resistance values it's not going to give you the exact one but it's going to give you a close one so you can use um resistor resistor color codes right here or again you can use your multimeter it's up to you to decide anyways see you in the next section where we're going to be discussing about LEDs in this section we're going to discuss the last component that we're going to need to build our first project they're going to be LEDs so if you open your pack they come in this shape and they come in all sorts of colors right here we have red blue green yellow so before actually working with LEDs and putting them in our project and working with them in the circuit what we're going to basically do is we're going to check the signs behind them and have a brief understanding of how they work okay so let me begin right here with something quite more popular so light bulbs light bulbs were obviously invented by Thomas Edison and let's see how they work okay so right here we have a battery right here and IT supplies current so what basically happens is current goes through this coil and it Heats it up so much so that it starts emitting light in this case it is red hot when we add more volt to this battery or a higher voltage battery right here that we're using we're going to supply more current basically making this coil heat more and it will obviously going to emit more light so in this case it becomes white hot so what is the problem with light bulbs and why do we even need to replace them well the problem is fundamentally speaking light bulbs are not light generating devices they are heat generating devices because the electrical energy that we're going to input the current is going to be is going to go towards heat 95% of it is going to go towards heat while only 5% of it goes towards light so in this case we're going to be producing excess heat and we're going to be wasting energy so we don't want that to happen that's why we have LEDs LEDs change electrical energy directly to light energy okay so led the long form is light emitting diodes light emitting is self-explanatory just as it just says light emitting it emits light what is the word diode let's check it out right here so before checking out diodes LEDs are something that we use day-to-day we have LED TVs Led buls Led Stripes that we put inside of our rooms to just decorate and all that so LEDs are something that we use every single day okay so what are doodes diodes are devices made from semiconductors okay so we know conductors and we know insulators conductors are what conductors are materials that can conduct electricity for example we can take this wire it's a conductor okay so we have insulators too insulators are the ones that are incapable of conducting electricity for example let's take this pencil that is just made of newspaper and in the middle we have semiconductors so they show the property of conductors and also insulators so let's check them out one it comes to semiconductors they have four valence electrons so let's take as an example let's take silicon it has 14 electrons when we arrange it it becomes 2 8 4 so it has four electrons on the outermost shell so it's obviously four valence electrons right here so when we align five silicon atoms we have five silicon atoms right here okay so when we put them in such a way they become stable let me explain so at the center the one with the that is marked with red is the center molecule and it has four valence electrons the electrons are represented with dots as you can see here okay so we have another silicon atom right here another silicon atom another silicon atom another silicon atom okay so one important thing that we see right here is the underlined dots right here these ones are shared electrons so electrons will be shared between this silicon at and the central atom this silicon atom and the central atom this silicon atom and the central atom this silicon atom and the central atom so if we add up the electrons right here we have one two right here three four and we also have four that we already have right here four valence electrons that we have from the beginning so when we add four + 4 it is eight so in this case it's stable so it doesn't want to receive or give any sort of electrons so in this case it's not going to conduct electricity why is that so there will not be free electrons to move so current cannot flow okay so it shows the property an insulator right here so right now we're going to use a method called doping and this is the method that actually changes semiconductors and just changes the game for semiconductors and actually makes them behave like conductors so let me bring this right here so we can check it out right here so earlier if you would actually look at it right here earlier we had five silicon atoms okay instead of having five silicon atoms replace that one silicon atom right here we're going to replace it with an atom that has five valence electrons so it has five dots right here so instead of giving one like every silicon atom right here it gives two so we're going to have instead of eight we're going to have nine electrons we could even count it 1 2 3 4 5 we have five shared electrons and we have four valence electrons that we already have on Silicon atoms so when we add that up becomes nine electrons so in this case it is negatively charged because it has excess amount of electrons right here and it wants to give those electrons so it's negatively charged that's why it's called the N Type n standing for negative okay so right here we're going to conduct electricity because we have excess amount of electricity we have free electricity we have that one electron that wants to what that wants to move freely and again we want to go back to what to eight electrons okay we want to be stable so in this case what do you want to do we want to give electrons so right here it shows the property of a conductor we can also use another method in this case we're going to give it three El so we have four silicon atoms right here the one marked with blue is going to be the three electron element so right here when we add all this up we're going to have seven electrons we have one two three electrons that are shared and we have four electrons that are again of silicon atom so when we add that up it becomes seven electrons so this will not contribute towards any shared electrons this element right here that has three electrons okay so in this case we are positively charged why is that so we have an electron deficiency and we want to what receive electrons because we want to achieve stability with eight electrons okay so it's called P type P obviously standing for positive okay so this is what is going to basically happen and one thing that we're going to finally need to check is this okay so with that in mind right here we have n types right here that have excess amount of electrons electrons electrons and electrons right here and we have the P type that have holes so let me discuss the concept of holes and what they are if you look right here we have hole a hole is basically an empty space an empty space where an electron should have been so if there was let's say four electrons like earlier like we had right here like we had right here exactly right here we just put the electron but right now we have is an empty space because we don't have an electron so basically holes are just representation of just um empty spaces where an electron should have been okay so right here in the nend type we have electrons over electrons over electrons while in the P type in the P type we have holes and holes and holes and holes okay so right here we connect the positive terminal of the battery you can see right here with the N type and the negative end of the battery with the p type in this case what basically happens is from the electron actually going towards the holes what's going to basically happen is they're going to start repelling each other so this one is negatively charged and this one is positively charged but they start to repel each other so in this case current will not flow okay so we connected the positive with the N type and the negative with the p type but right now when we change the direction of the battery and we connect the negative with the N type and the positive with the B type what basically happens is electron flows from the N type to the P type so the electrons flow from the N type to the P type so in this case they're flowing from higher energy level to a lower energy level okay so in this case when they're flowing when electrons are flowing from higher energy level to a lower energy level they're basically going to be releasing energy and as you know the rule of conservation of energy energy is neither created nor destroyed but rather uh taken from one form to another so when they release that energy the electrons they release that energy in the form of light so when they move from higher energy level to lower energy level they'll be losing energy and that energy that they're going to be releasing is going to be in the form of FL so right now what basically happens is we directly change electrical energy directly to light light energy so we don't need to have you know excess heat and all that like light bulbs did okay so you might be wondering then what is the P type of uh you know an LED look like then in real life because it matters like what what part of the battery that you connected to so if you look at your LED right now let me just bring it up close you look at it right now let me just actually me get this okay so if you look right now if you look at your LEDs the LED legs right here they're not even one is longer and one is shorter okay so the longer one the longer one if you look right here the longer one is the positive and the shorter one is the negative the longer one is the P type while the shorter one is the n type okay so if you look right here we're going to connect the positive end of the battery right here with the Positive the longer side right here and the negative part of the battery with the negative terminal okay so we're going to actually check um on the next section on how to actually assemble our components that we've learned so far so see you in the next section so now we're actually going to be in the exciting section of actually building and assembling what we've learned so far so we have our Arduino right here we have our resistor which is a again recommend it to be 300 to 400 amps uh we have our LED right here we have a connecting USB right here I'm going to be connecting uh my Arduino to a laptop and I have my Arduino breadboard right here okay and then I have my connecting wires okay so let me Begin by connecting the Arduino with the breadboard if you have an Arduino uh Uno you don't need to connect your Arduino with the breadboard all you need to do is a hole again so all you do is again connect it directly to a connecting wire okay so second thing I'm going to need to do we're trying to build a circuit actually so let me bring the circuit right here okay so we've got our aduino connected we want to connect it to the 5vt so let me go right here and let's try to connect it to the 5vt there's the 5V connected right there to the 5 volt okay let's say put it around 25 okay just put it randomly on 25 then now what we want to happen is we want to connect it to a resistor okay so let me bring my resistor right here bring it right here and let's let me just try to connect it a bit if you can see it okay so one thing you notice is I connected it across cross so as you remember this row is connected this row is connected but these two rows are not connected to each other because they have a gap as I told you guys earlier so if I connected it let's say in the same row okay horizontally in the same row let me just make this a bit more thin let's say connected it this way okay if let's see the resistor is not connected properly sometimes this happens you have to push it in okay and if the resistor is not connected properly what is it going to happen is basically this type of circuit we have our again Arduino right here and directly connected to what to our LED so it's going to fry our LED with a one that's happen again so if I connect it abroad though if I connect it somewhere where it's not connected again let me just go just make this a bit more wide it's a bit of a hustle to even connect resistors to be honest so you guys can see I connected it uh abroad is current will flow like this from the 5vt to the connecting wire right here goes horizontally unless it's not connected right here what's what is going to basically happen is it's not going to what conduct electricity so at best at the worst case scenario if you connect it like this is nothing happens so the LED just not light up it's not going to get fried but it's not going to light up all you need to do again is connect it properly and uh you're good to go so we want to connect it what when we connecting a resistors we want to connect it across if not we can even connect it vertically okay because again as I said they're not connected so we want this one one leg to be on the connected side and one leg to be on a side that's not connected anyway with the again the circuit okay with that in mind let me just bring my LED and before actually doing that we first need to identify let me just make this a bit more wide uh we need to identify which one is the positive sign and the negative side as I've told you guys earlier the longer side is the positive and we want to connect it to the positive terminal as I said again the P the P type okay this is the P type and we want to connect the negative side with the negative terminal the end type so you want the longer side to be the direction of the positive so I have the longer side right here and I want to connect it right here as you guys can see okay now finally we connected our Arduino current is Flowing we've connected our resistors we've also connected our LEDs the positive side and the negative again so if you look right here actually this is the positive side okay if you look at even the diagram eally is it's positive right here and we have the negative right here okay so again it's going to go all the way right here and to the negative terminal and how do we get the negative terminal in an adino is let me go all the way you guys can see it there's a sign that says G and D you can see it right here G and d stands for negative or ground okay so if I put G and D right here it basically means it's negative there's no other meaning towards it all right so I want to connect the negative side of my LED so all I need to do is push this and we're done building our first circuit so right now let me bring finally let me finally bring our uh connecting USB so let me connect it to my laptop okay then let me connect my Arduino there you have it we have our first up and running LED circuit let me turn off the lights so you guys can see it better so there you have it again this is a simple circuit what is going on oh you see resistors that I was talking about earlier sometimes they disconnect when we move them again and what happened was again it turned off but our LEDs again were not fried as I said again because current cannot flow through okay so with that in mind uh see you on the next project in our previous section we built a simple circuit that lights up an LED so let me bring light right here so if you look close enough we used our Arduino as a power source nothing more than that something that outputs 5 volt we only used it as something that outputs 5 volt but also can output a voltage a battery can so in this case we can build the same exact project if we have a 5vt battery okay so instead of using an Arduino as a power source we can use a battery right here I have a 1.5 volt battery as it's just found commonly inside of uh the remotes and all the all the things that we use so I'm going to use a 1.5 volt but this means that current is going to be less okay so voltage is directly related to current so I'm going to have less current basically it's going to the light is going to be a bit more dim so to actually di demonstrate that let me turn off the light maybe then you can see it if you cannot let me just just bring this paper right here and try to Overlay it with the paper maybe then you can see it can you see it okay there we go and let me just turn it off and turn it on so you can see the difference you know what it there we go it's very dim though you can see it if you it's actually in dark environment but anyways this raises the question why not use batteries instead of Arduino because when you look at batteries they look more reliable they're cheaper and again they're easier far easier to just uh move from place to place so they're more convenient so when you when you look at Arduino right here we have all these things you you need to be careful with arduinos not only that too but they're really expensive relative towards a battery so this raises a question why Arduino why are we using an Arduino so one thing you guys need to know about Arduino is Arduino acts as a power source but it's just definitely more than just a power source all right so it is a power source it acts like it but definitely it is more than just a power source even by looking at this pens and looking at all these things that we have right here we can see that it's just definitely more than a power source we're only talking about the 5vt right here so when you look at all these things that we have right here it is definitely more than a power source so what is the purpose of an Arduino Arduino is used to code our electrical components for example example let's say I wanted to code this so that it turns on and off every second so it's going to turn on for a second then turn off for another second turn on turn off doing it in the loop okay so it's going to turn on for one second turn off for one second turn on for one second turn off for one second and keeps going on in the loop so how do I do this using a battery I have to physically come in right here turn it off turn it on count a second turn it off count a second turn it on count a second turn it off and obviously this is not coding but with our uino we can set this up we can set up we can set this up so that we can actually code it to actually make it blink so we're going to turn it on for one second turn it off for one second we can do this using an Arduino so Arduino what does it do something important that it does is lets us code our physical components I'm sure you use websites and applications and they're coded digitally so what if you wanted to code our physical components for example let's say we're working on a robot or some other project this is where ardino comes in this is where uino comes in and lets us code our physical components so definitely Arduino acts as a power source but it acts as an intelligent power source all right an intelligent power source that we can code okay so it's definitely more than just a power source all right with that in mind let's check how to actually uh code our Arduino so how to actually put transfer code to Arduino so see you in the next section where you're on my screen and we actually check on how to code using an Arduino so far we've learned that arino is more than just a power source and it can do a lot more especially letting us code our electrical components so to start coding our arino microcontroller we're going to need a platform to write code on so in this case we're going to need a code editor so it's going to be different depending that you're going to be using a physical arino or a digital Arduino on a simulator for those of you who are using a digital Arduino on a simulator all you need to do is go to this code right here this code section right here and choose your preference so if you're using blocks you can use blocks right here you can change it to block or if you prefer text you can use text right here but I highly suggest that you guys use text as I'm going to be using text for this course okay so for those of you who have a physical Aro all you need to do again is go right here follow this link and download the uino depending on the operating software that you have right here so if you have a Windows you're going to download from here if you have a Linux from here and a Mac you're going to download from here so for those of you who don't have uh Linux Mac or Windows or maybe for example you're using a Chromebook all you can do is go to your ardino web editor and touch the code online and sign up and you can use this Arduino web editor so without downloading anything you guys can just start coding to your Arduino that's all you need to do start writing code to arino so once you're done downloading the arino code editor it looks something like this there we go it looks something like this it has void setup and void loop we're going to check what these means and not only that too but we're also going to create This Blink project that I mentioned earlier of the LED earlier on the next section okay so now what you want to do to write code to our adino let me go to our code editor and one thing you need to set up is go to our Arduino and choose our board and our communication Port okay how do we do it we go and select the board that we're using for example let's say I'm using an Arduino Uno I go to Arduino Uno and select it obviously I'm using an Arduino Nano so I'm going to go back to Arduino Nano and select it so you're going to choose the REO board that you have right here once you're done with that you going to check the communication Port that you want to use right here I only have one communication Port so I only have one comp Port so I don't have to stress and I can just continue and just say okay but let's say we have two maybe two communication ports let's say I have another communication Port right here underneath and you do not know which one to use to know which one to use all you need to do is basically plug off your Arduino so I'm going to plug it off and once I plug it off it's going to turn off the communication Port is going to be off so you're going to know which communication Port is tied to your Arduino okay there we go and go back to touch okay then I'm going to need to write code so this is a starter code this is a code that always exists for every sketch okay so this is going to be a code from the complex ones so the easiest project they're going to contain void setup and a void Loop okay so what is a void setup this is where we actually put our setup code okay and it's going to run once importantly it's going to run once okay so we're going to put our setup code right here and we're going to only run it once okay when it comes to loop we're going to put most of our code and our main code right here and we're going to run it repeatedly so we're going to run it over and over and over and over and over again okay so let me go right here and to basically notify that our our Arduino what pin we're going to be using we're going to use this builtin function called pin mode okay we're going to use something called pin mode all right there we go and we're going to tell it what pin we want to use right here I have again from two to 13 I have digital pin 2 to 13 so I'm just going to choose random number let me just choose seven for now so we're going to use pin 7 okay then once we're done letting uh our our Doo know which pin we're going to be using we're going to notify it of how we're going to use it okay so we're going to tell it if we're going to use it as an input or we're going to use it as an output okay so if you want to use it as an input we want to what we want to receive data from the pin okay so when we want to use it as an output what do we want to do we basically want to send data in this case we're going to send what electricity okay we're going to send voltage okay so we want to use it as an output in this case once we're done with that for every line when we finish a code for every line we're going to finish it with a semicolon okay so one thing to keep in mind is for all of you is capitalization does matter so you cannot write down pin mode let's say with a small M if I did that and let's say I want to verify the code it's going to show me an error message so one thing you want to keep in mind is every time capitalization matters and code Okay so even matters for this output let's say I say output right here with no capitalization with no proper capitalization it's going to give me an error okay so capitalization is very important in coding and let me just run this right now I don't see any error okay there we go so I wrote this down properly so what does this code do it tells our aduino that we're going to use pin 7even how do you want to use it we want to use it as an output so once we're done notifying our Arduino and we're done setting up our pin we're going to go to our Loop okay so how do we uh tell ourin know if you want to give 5 volt and Z volt we're going to use something called digital right so right here too again specifically capitalization is very important so what pen do we want to write we want to write down pin seven that we already set up right here there we go and once we're done with that you want to tell it if it's going to be high or low high basically means I basically I means 5 volt okay High means 5 volt 5 volt right now you want to keep this in mind so high just basically means what 5 volt okay then once we're done with that what do we want to do when we want to make it blank we want to what we want to write down the same cot right here again capitalization matters and put pin seven and you've guessed by now we're going to use low we're going to use low so what's what is it going to do we're done setting up our code once so we're GNA let notify our do we know what pin we're using and how we're going to be using it then once we're done with that it's going to run this code as a loop it's going to run it repeatedly right here okay so it's going to go pin seven it's going to turn it high it's going to turn it to what to 5 volt right here turn to 5 volt and then when we turn it to low we basically turn it to 0 Vol or off 5 Vol or on okay that's what we're going to do so let me just do is verify the code right here in case we have an error it's done compiling right here properly and then what we do is upload it okay and we're going to upload it to our Arduino but one thing I forgot to do is to set up our arino so we need to set up our adino so one thing I need to do right here before even setting it up and wiring it as I told you guys before in the precaution safety section what I told you guys was to turn off our adreno first we build our circuit and then we turn it on okay okay so let me bring my red pin right here and attach it to pin seven wait that's pin two pin seven is right here okay there we go put it right here put our handy resistor right here we want to put it at an intersection there we go okay then we need our LED I'm going to need to know the big side is obviously the positive there we go and put that right here the positive with the positive side and then we're going to go back to our gnd D or negative terminal let me go to g& d right here there we go so I want to check again up close if I'm actually correct or I'm making mistakes right here so I me I'm just going to bring it closer to myself and check it for myself okay that's seems fine nice okay let me check the long side again okay there we go I'm correct all right I'm done checking now I can turn on my arino let me turn it on okay I think it's the resistor right here okay it was the resistor so let me just touch it again okay there we go it's working now but can with something it's not turning on and it's turning off it's just not blinking we cannot see any blinking right here here can you I cannot so what is happening so let's analyze our code so what we did was set up our code everything seems fine right here everything seems appropriate and then what happens is basically what happens is we digit the right and we set it to high then we set it to low then we set it to high and low and one thing you notice is it's going to go at very fast speed it's going to be really really fast computers are really really fast so we cannot notice this with our naked ey so right here look at it it's going to go high then it's going to go low really fast then it's going to go high again it's going to again go on a loop as I said again so it's going to go high low high low very very fast that we cannot notice it so what do we need we need a delay so we can notice it so we're going to need a delay so we're going to do that we're going to do is use this delay function okay so when I say 1,000 that's going to be 1 second so it's going to capture it in milliseconds okay so you're going to write down how much seconds that you're going to delay it when milliseconds so we want to delay it right here and put our semicolon after every line there we go and we want to put the delay right here again delay of 1,000 then there we go with our semicolon and let's run it again so let me just verify it right now okay then I'm going to upload it so it's going to turn off for one second and turn on for one second turn off for one on off on and it keeps going on so let me go on off on off so we basically build this okay so one thing to keep in mind again is that we use millisecond so when I say 1,00 milliseconds it basically means a second so it's going to receive a millisecond okay there we go so we're done we're actually building this so actually in the next one we're going to check so in the next section we're actually going to check a few things about variables okay so I have homework for you guys so before moving on to the next sections you're actually going to do these homeworks okay so what we did right now is obviously create This Blink again so we used one pin and create This Blink so what I want you guys to do is create a traffic light so we have our green color right now we've got our orange one and we've got our red one okay so you used one pin to set up everything for One LED so how many pins are you going to be using using for three LEDs you're going to be using three pins okay so you're going to be using three digital pins so you're going to put Green in front so instead of actually uh the red one it's going to Green is going to be right here then we're going to have yellow and then we're going to have red okay so we're basically creating a traffic light so I want this to I want this to do is basically okay what I want this to do is I want this to delay for 5 Second and then turn off so it's going to be on for 5 seconds okay then when this one is off obviously it's going to turn yellow for this case yellow is a shorter one so I'm going to choose 1 second and red I want to make it the same as the green light because that makes sense so we're going to make this 5sec to okay so I want you to create a traffic light a working traffic light okay so you're going to be using three pins creating a resistor right here using the resistor right here then obviously lighting up your LED then going back to GM and D okay so they're going to be using the same gnd D so if I bring let's say the second wire one thing you guys don't know is let me just bring another wire okay there we go another wire so let's say I have my ground right here of the second LED of the yellow one let's say for example and what you're going to do is connect to the same gnd D okay so you're going to connect the same gnd D It's okay but you're going to be using what different pins though you're not going to be using the same pin you're going to be using three totally different pins so you might be using D5 D7 d8 it's up to you so yeah you're going to be building this project for yourself so before moving on the to the next section so pause this video and work on it if you are not sure of how the circuit is supposed to behave again you guys can use a digital simulator okay afterwards I'm actually going to build it with you guys in case you do not know you can refer back to the next section where I'm actually going to build it okay so so now we're actually going to work on our homework so I'm not going to bore you guys out trying to build this as I only need to use three different pins and do exactly the same thing so the necessary information that you guys need is that green is connected to seven so the green pin right here the green LED sorry the green LED is connected to what the pin the digital pin 7even okay so it's connected to what the digital pin 7 the same goes for yellow it's connected to digital pin 4 while the red LED is connected to thisal pin 9 okay that's the necessary information that you guys need so now let's code this so first we're going to need to do a pin setup so we're going to need to go to pin mode and obviously set up our pins so we want to let our aduino know what pins we're using so let me just copy this right here paste this and we're using pin 4 so let me write down pin four right here four we're using it as an output yes we are let me again paste this and we only have pin n so we're going to use pin nine here too nice and once we're done with that once we're done setting it up let me just remove this code right now CU we're not going to be using this we're going to digital write our pin what our pin seven for green so we want green to light up first so I'm going to go for pin seven then I want to set it to high and finish it off with a semi col it then I'm going to copy this again copy this then I want what I want pin four to be high but before that actually before actually going to four what do I want to do I want to delay it okay I want to delay it for how many how many seconds 5 seconds so it's going to be 5,000 here so I'm going to be using milliseconds here 5,000 then I want to do what I want to turn it off okay so I want it to be low so let me go here and I've got pin seven here then I want to set it to what to low okay that's what I want to do okay when it comes to um when it comes towards the the yellow LED what do I want to do I want to do is the same thing almost but I want to change the delay to what to one second don't I so let me save right here and set this delay to how many one second or 1,000 milliseconds and I want to change the pin number again I want to change it to four so go four and I'm going to go four again okay this is for what let me just write this description down or comment yellow this one is for green so let me write down Green right here then I want the red one it's going to be the same exact thing but I want to change the PIN with the green just copy that again do that and I want to change the pin number to what to nine okay all right so I think I'm done with this one so let's check if it's actually going to work so let me verify this okay seems like it's working let me connect my ardino before uploading it so let me go here connect my adino and let's upload the sketch it says done uploading so let's check it out there we go there we go it's working nice that's great and all but if you look closely let me go very close on my camera right now like really really close forget about this paper now okay so I want you to very look at this let me bring bring it up close here so if you look at it right now can you see how much I stress the G and D like it really looks really bad this is by the way the gnd D all these three wires are connected to gnd D okay so what can I do to fix this so let me just bring an extra wire right here okay an extra wire let me zoom out right now for now there we go so I have this extra wire what I'm going to do is let me just remove this three g& D pins for now before actually building the circuit what do I want to do I want to turn it off I want to turn my adino off first build and then we upload and then we run it okay so got my gnd D pin right here connect it connect the gnd D pin if you cannot see it I'm connected to the gnd D pin all right now what do I want to do okay so I'm going to use this vertical stripe can you see it points the negative there's negative and positive right here I'm just going to use the negative one as this just again convention all right so I'm connected to this one so as I said again when it comes to breadboards the edge ones are connected all the way vertically so I can basically do is what I can just connect it to this one the vertical line again the same for this one use this vertical line for the g&d pins and this one for the GMD pin I'm going to use a vertical one there we go now it looks more nice okay so let me just again turn on my Arduino and run this everything should be working normal let's check it out first okay so 5 Seconds there we go all right it's working really really great okay so let's say I have a problem I have to wait for like 5 seconds and I just say it's just too long for me and I just want to reduce this to 3 seconds okay so what what should I do I want to change the green and red to 3 seconds I I I like the yellow one it's one second it feels nice but the red and yellow just feel too long for me okay so what do I do I go right here and change 5,000 to 3,000 not only that too I have to go back to Red then go change it to 3,000 again okay then have to upload it so it's going to work for three seconds now but okay let me just let's just check it out working okay there we go it's working okay it's a bit faster now just count again one 2 three and change over okay there we go it's working pretty fine all right but I have to go change it at two separate places so I have to go right here and change this to 3,000 again 3 seconds so I have to go right here again and change this to 3,000 just think of me having lots and lots and lots of LEDs right here let's say I have five or six I'm going to have to go change it what six places I don't want that to happen so how do I do avoid this type of mistake so we're going to learn something called variables all right so first before learning about variables let's talk about this box here so I have a box right here okay so this box No Label on it you do not know what is inside until you open it when you open it you know what's inside okay so it has no label again it's just empty but to save us this effort and let's say I just checked it and labeled it right here and named it microphone box okay so I just gave it a label so it's going to tell me what is inside before even opening the box so right now by just reading this I can say is okay this has some mic equipment inside of here right okay this has mic equ before even what opening it all right so this is the nice thing about variables so what do they do is basically refer to things all right so they just basically refer to our data so we can can refer to our data without actually changing anything about our data our label does not change anything about our box all right doesn't change anything all it does is what all it does is reference to our box what is inside the box that just what it tells us so how do we set of variables here and we're actually going to see even a second purpose of variables the first one is to reference things we're going to we're going to check the second the second uh use of variables so let me go right here let's see how you set up variables here so all you need to do is go right here and use the keyword let if I correct I don't think use the keyword let here so all you need to do is um write down a name so let's say I want this to be delay time so I just write down delay time okay so I'm going to set this to 3,000 and close this let me just verify if this is even correct and it says no it's not does not name a type Okay so so right here all we need to do is go right here and say let let delay time we do that right here let does not name a type so you might be wondering for those of you who are using JavaScript and all that we have to tell it what type of data we're putting inside right here we're putting what we're putting an integer all right so we have to let it know the type of data that we're storing right we're going to say is int inte teer a it's an integer number so let me if I let me just verify this again should be working pretty fine now can you guys see it so we have to tell it the type so when you're using ardino you're going to have to tell it the type of variable that we're using so in this case it's an integer I'm defining here and obviously I'm going to give it a name so I'm going to call this delay time again this has nothing special on it so I can just even call it some something else that is unrelated to it I can just say you know what it's green or um I can just say phone or I can just say anything you get me but I'm going to obviously put delay time because that's what is the use of variables to give us rightful information of what this is so even before somebody reading my code they can understand oh they can understand before reading this code is that oh this is delay time this is supposed to be the time that it's going to delay inside obviously this again this LEDs okay so I'm going to go say delay time and set it to 3,000 all right so let me just set it to 3,000 so I'm going to remove it this delay time right here so I'm going to be using it how do I use it I just use it as a normal thing I'm just going to see delay time are you defin it I can use it multiple times all right all right for also for red I'm going to go right here and use Del time underscore time all right perfect that's all I need to do if I verify this right now I don't get any error all right everything's sounding great if I upload this I said again a variable does not change a thing about what it's referencing so I earlier said 3,000 here and basically what it's just doing is delay time is equal to 3,000 here so it's basically putting 3,000 the computer is manually putting 3,000 here all right instead of delay time that's just what basically it does so second usage of variables here is that you know what this is a bit too fast for me this this thing is just really fast it's just going 3 seconds and then 1 second uh and then 3 seconds this is very fast for me I just want to make it 4 seconds all right so I can just do right here is just change it from one spot I don't have to go multiple spots to change it I have to find it ones I can do is just change it from one spot and say you know what that's what I want let me just verify this let me upload this I want it to be 4 seconds I wanted it to be in the middle I don't want it to be too slow I don't want it to be too fast all right so look at this I upload this right now it goes 4 seconds so let me count this one two 3 four all right there we go so it goes for 4 seconds all right all right that's all you need to do when it comes to variables that's why we use them a lot all right so instead of using pin 7 right here just saying 749 okay I can change it again to for somebody who does not know um what I'm writing down before somebody even knows what I'm writing down right here by just defining these variables I just save them the time from reading the code it can also work for yourself when you come back to this code all right so I can just say is you know what I can call this digital pin digital pin equal to let's see again we have seven right here so digital pin let me just see seven right here all right let me just see digital pin sore 7 there we go then I again I can write this down for for four write this down for nine right nine here right four here there we go and obviously replace this digital pins right here so I'm just repeating pin I'm repeating seven right here on pin mode and also on digital right I'm repeating it over and over again can you guys see the difference right now so let's say I'm changing a pin I have to change it at three separate places I don't want that to happen so all I have to do right now is do the exactly same thing write down digital pin 7 it's going to out to complete it for me and go say digital pin 4 and then digital pin what digital pin n okay so I'm just going to replace this again so one thing you guys need to know is by using control D or command D you can just select the same number over again so you can select the same thing over again see I even selected seven right now I even selected the seven from the digital pin seven right here so you need to be careful so okay I'm going to do is Select this two seven right here and I can edit them at the same time okay edit this at the same time there we go when it comes to four I only have two fours right now left do is this and again set this digital pin four and when it comes to nine I can can use control D select two then digital pin n there we go it's not supposed to change anything about our code but it should make it what a whole lot nicer and clean all right so let me verify this again if it's working properly okay everything seems fine let me upload it let's check if everything is working properly as it should all right nice okay hey that's good it's working really really nice so you guys learned about variables so again as I said one thing you should know about variables is as I said again one thing you should know about variables is what they do not change anything all they do is what reference again like I talked about the Box the label on the box just basically reference what is inside of the box but nothing more than that all right so that's all it comes to variables so all they do is just refer data they just make it easier and cleaner to to store data all right all right with that in mind let's move to the next section all right so let's recap what we've done so far so at first we began with the 5vt right here we began with the 5vt and we built a simple LED circuit afterwards we use these digital pins right here and what we did is again build a traffic light okay so what are these pins marked with an A and A number next to them we're going to check them out in the next few sections by the way these are called analog pins so in the next few sections we're actually going to see the difference between analog pins and uh digital pins not only that too but we're going to see their purpose and why they are important in the Arduino world so um see you then all right so let me show you guys what I did right here so what I basically did all right is that I set up the basic 5V LED circuit so we have a 5vt right here connected to the red uh connecting wire and then we have a resistor and we have our LED and then we go back to the gnd with the black wire that's all I did that's what we did when we started this course Okay so so let me go over to my screen right now and let's start coding so right here let me first give this uh variable name so I'm just say a red pin all right then let me give it a number let's say we using pin 4 right here analog pin 4 let's just say that again I just took it by random and right here what we do is again as we did for digital pin what we did was pin mode right then we put our what our pin which pin it is and then how do you want to use it do you want to use it as an output or as an input always put a semicolon at the end of each line all right that's what I did right here but there is a problem right here so right here when we using digital pins right here we did was only put the number right so let's say I'm using digital pin 4 right here let's just say that I'm using digital pin 4 but I'm doing that what happens when I'm using digital pin 4 what I did was just put a number right here and set it up like I did for an analog pin so right here how do we know the difference between digital and analog pin so how does Arduino know that we using digital pin 4 or analog pin 4 right here and weo does not not know okay so every time to differentiate an an analog pin from a um digital pin what we do is put a capital A before it all right before the number that we're going to use we always put a capital A so it's going to differentiate and it's we're going to know actually which pin we're going to be using so right here Arduino will not be what will not be confused if you want to use the digital pin or the analog pin okay so we're going to do is what put a capital A beforehand all right so once I'm done setting up the pin mode right here what I need to do is go here all right so what did we do right here we said digital right and we set it to what what do we do we put the red pin right here and then we set it to high when we were using a digital pin so right here it makes sense to write what analog pin there's something called analog right okay we do that and we see red pin okay the pin that we're going to be using and then we're going to put a value so right here I'm just going to put 255 and I'm going to come back to this and actually explain why did we put 255 so let me just remove this right here because obviously when not using a digital pin right here let me just remove this and all right so let's verify it and let's upload it okay let me upload it right here and it's done compiling it's uploading and it's done uploading all right so let let me remove my Arduino from the 5vt and let me move it towards the digital pin not digital pin sorry I said um analog pin 4 let me just do that there we go I moved it to analog pin 4 right here all right so right now it's lighting up as how a 5vt lights it up and addal a digital pin lights up the LED so again you might be confused on why did we use 255 right here what is the use of it not only that too but what's it's a very odd number you know why not 300 why not why not 20 200 why 255 specifically okay so let's see the science behind it to understand why it is 255 and so the question Still Remains why are we using in so right here let me start from Something That We're familiar with we use digital WR and then we set our pin what pin we're going to be using and then we set it to either high or either low obviously High means 5 volt which basically is on low means Z volt which basically is off it seems to be working perfectly fine so why do we need integers to represent this to represent high high is represented by what high is represented by 255 low is represented by zero why do we need integers to represent that because this gets the job done perfectly right so the problem here is when we're using high and low the problem that arises is we only have two options we cannot choose anything more than high or low let's say I want to set it to medium let's say I want to set it to well I want it to Output 2.5 volts literally the medium the half what happens I basically cannot output Med medium because I either I can set it to high or either I can set it to what to low so this is where integers come in they come really really handy and they allow us to have intermediate values so if I wanted to set it to medium what do I need to do all I need to do is divide 255 by what by two basically giving me half so let me let me just bring a paper right here okay there we go so let's say I want to do 255 I want to I want the half of it 255 is what if you remember 5 volt all right I want to Output half of 5 volt it's going to be 2.5 volt right here all I need to do is what I need to do try to find X right here how much I should be writing down and then do the math and once I do it X is going to come approximately to 127.5 which you can round up or round down which I'm going to round up to almost 28 so what does integer allow us to do integers allow us to have intermediate values what else let's say I want to do is what you know what I I don't want it to be half I want it to what I want to do 20% of what the original high that we had I want 20% of it I want 20% of 5vt I want to Output 20% of 5vt so let's do the math right here what's uh 5vt 5vt is currently 100% what is 20% all I need to do is find the voltage do the the math right here keep on doing the math right here 20 okay it's going to be 0 when you do the math 0.2 * 5 is going to equal to X when you do the math right here 0.2 * 5 all right so basically what is this five * 2 over 10 when you do the math right here this is going to be 2 over two so we're going to have one there we go one is equal to what x basically we're going to outut one volt there we go so basically what just allow us to do is what we can find any value so we can have any intermediate value between what between high and low so we can have any intermediate value between high and low because obviously if I had let's say high right here and low let's say I write down medium for uh 2.5 volt and then I write down another name for it obviously you cannot name every instance you cannot name every obviously value of voltage so we're going to be using integers doing the math and after doing the math we we can do what we can find our desired value and then output the voltage so basically we can what we can control the amount of voltage that's coming in to our Arduino to coming out of our Arduino so basically what happens basically we can create dimmer and what brighter light so we can create intermediate values of light but one thing I want you guys to keep in mind is okay one assumption that you really really need to know is actually how it works is it doesn't change physically so as I said again when we're turning it on 5 volt it's basically what it's on and Z volt it's basically off so what happens is let's say we're trying to write down 2.5 volt right here we're trying to what we're trying to Output 2.5 volt what Arduino does is all right what Arduino does is it turns on for half the time for half the period of time and then right here it's Zer volt let me just specify it the one on ground is z volt right here so what happens is what what happens is it turns on for half the time time turns off for half the time turns on for half the time turns off for half the time it does it really really really fast that you cannot notice it so for us it's going to appear as what it's going to appear as dimmer but what basically H is happening is what it's basically doing high and low series of highs and lows for what doing a series of highs and lows for again a given amount of period of time there we go so that's how we output how much 2.5 volt we turn on for half the time we turn off for half of the time turn on half the time turn off half the time so basically we're going to have what 2.5 volts okay so physically the same thing is always high and low series of 5 volts and Zer volts but using integers allow us to do what they allow us to what they allow us to use intermediate values all right so before running the code let's do a simple recap so what we did is what we set red pin to analog pin 4 and we set it as an output right here our red pin and we use the analog right Command right here analog right Command right here and we set it to a maximum value of 255 which corresponds to 5 volt right so let me just upload it right here and this should light up it does okay nice so let me go right here and let's just say I set it to a value of 40 just do notice the difference so let's see if it goes dmer and when I do that you see what happens right here you see what happens it does not fully turn on so even uh you guys cannot see that it's fully turned on it's not even turned on at all all right I can see that it's not turned on too so there is an error on going here so one error that um I came here to fix is that what I did uh round was right here I used analog pin 4 so one thing right here let me go closer is that you're not supposed to use this analog pins this a pins for this purpose okay what you're supposed to use is this digital pins right here these digital pins that are marked with a symbol right here so let me go closer again for you to see it can you see thisal pin N9 right there it has a DOT on it a small Dot you see that let's compare digital pin 9 to digital uh pin 8 if you do that digital pin 9 has a a bit of a DOT on the very edge if you look at it not only digal pin 9 has it digal pin 10 digal pin 11 digal Pin six digital pin five and digal pin three have the uh DOT sign on them all right so let me go right here and I have to connect is this this um these digital pins that are marked marked with a DOT or a squiggly sign so for me it's a dot but if you go over to my screen right now just go over to my screen if you go to my screen right now what happens is there's this quickly sign I'm just turning on an ardino an image of an Arduino Uno and if you look closely there's this quickly sign in front of this digital pins so what happens again is when you're using U um Arduino Nano the board that I'm currently using is an Arduino Nano we use we have is what dots that Mark this unique digital pins I'm going to get to using them all right but when you use an Arduino Uno we have a Squigly sign so it will vary the sign will vary depending on the board you have right so look for U if you're using any other board is look for a a unique mark on your digital pins okay so if you look closely here it says it supports something called pwm okay okay so pwm stands for pulsewidth modulation so what basically this means is let me just explain it in a very very simple term all right so before running the code let me just let me just make sure that you understand the signs behind it okay so it's quite simple so what does this mean is let's say I want to turn on my uh I want to turn my uh my Arduino to 2.5 volts I wanted to Output 2.5 volts all right if I wanted to Output 2.5 volts let me just show you how you can do it so what happens is when let's say an Arduino outputs 2.5 volts what happens is it goes to 5 volt half of the time and it goes to Zer volt half of the time it goes to to 5 volt half of the time and it goes to um Z volt half of the time let's say I want to turn it on to let's say I want to turn it on let me bring another paper let's say I want to turn it on to uh 1 volt all right so let's say I want to turn it on to 1 volt let me just turn on there we go let's say I want to turn it on to one volt okay how do I do that all I need to do is just again draw the graph of volt versus time this is time right here the time volt versus time graph so what happens is it turns on it's 5 volts right here and Z volts right here so what happens is it what it turns on for a very short period of time it turns off for a long period of time you see that turns on for a long short period of time again for 5 volt for a very short period of time turns on for a long turns off for what for a long period of time okay that's just a rough sketch of how one volt will look like when it comes to 2 2.5 volt what happens is again is what half the time it turns on half the time turns off half the time turns on half the time it turns off so we achieve this voltage how do we do it we use the two ends 5 volt and Z volt and we what we fluctuate between them so we change between them okay that's the science behind it and one thing I want you guys to know is this it it happens at very fast speed that we can't notice it turning on and off so we don't see it turning off and like for like 5 volt for half of the time and turning off for half of the time it happens at very very fast speat I'm talking MCS that our eyes cannot notice the difference okay so for us it's going to appear as a dimmer light even though it's turning on and off on and off at very very fast speed so let's go to U our code and let's write it down to actually see what happens so let me again plug my Arenal right here okay so right here let me actually actually instead of plugging it what I should do is let me bring it closer to you guys so right here one thing you can notice is we can use those quiggly signed can you look at it those pins again with a squiggly sign on them so in this case digital pin 10 has a squiggly sign digital pin n has a squiggly sign let's just use digital pin n right here okay so use one of those uh pins that have a squiggly sign or a dot in front of them so digal pin N9 have to go right here all right so I connected it to digal pin 9 and again a simple LED circuit so let me connect my adrino board right here okay let's go back to our code let me go back to my screen right here all right so I'm going to say is what pin n okay then I set pin R put as output and Pinn 40 okay so I'm just upload it right here I uploaded it it's not even fully turning on maybe might be the resistor right here it's not the resistor am I correct with the pin I might I think I'm doubting that okay I got it to pin eight now I'm correct with the pin it's pin n is right here oh there we go we have a dimmer light I don't know you might notice it or not so what I'm going to do is uh to notice it is let's go to my screen and let's write some bit of code so that you guys can actually notice the difference between um a value of 40 and a value of 255 so let me just say analog right red pin and set it to 255 okay then we're going to set a delay again delay function Let's us put uh delay for the amount of millisecond so right here I'm going to set it for 1,000 milliseconds which basically means a second all right okay so we can see the difference delay again 1,000 so let me just run this again so let me verif verify this everything's running right and smooth all right and let me upload it okay all right can you see it it's going brighter and then dimmer brighter and dimmer brighter and dimmer so what I'm going to do is turn off the light right here so you can see it way better okay let just turn off both the lights on the spot you can see it better now it's going brighter and dimmer obviously the brighter is 255 while the dimmer is obviously the number 40 okay so let me just go back to our light right here turn off turn on both lights so so we've seen how P pulsewidth modulation right here works okay so I'm using what pwm all right all right so I'm using this pit so one confusion that happens is uh what I see most often is all right what are again this p pin are the analog pins the ones that are marked with with a d pin and then a number next to them and that have again a DOT or Squigly sign are they analog pin or are they U digital pin because if you again look at the code right here we're using analog right so if you look at the code right here let me just highlight it again if you use the code right here we're using what're using the command analog right oh my God this is getting annoying Jesus just let me just go right here there we go analog right it's going to analog right but also one thing you notice right here is what it's marked with a d which makes it a digital pin so I be wondering is this a digital pin or an analog pin so one thing you need to understand here is the ones that are marked with a with a DOT or a squiggly sign these special digital pins i' would call them special digital pins what um they are is they're both okay so they're digital pins they're also analog pins right here when we use the analog right command we use them as what as an analog pin okay so we use them as analog pins and also one thing you need to keep in mind is we can also use them as digital pins so let me just turn off all this code right here if I just say dig again not changing the not changing the pin right here I'm going to say it's digital pin all there's to right right here and again when we use this command we only can say high or low We cannot put a number here just going to say high okay so let me just upload it right now as it is just upload it on the spot and again let me connect my Arduino right here I forgot to connect my Arduino I can't upload it because I did not connect my arino let me just upload it right here it's stun compiling verified the code and done uploading can you see that it's lighting up so one thing you need to learn about these St pins that are marked with a squiggly side or a DOT is we can use them as an analog pin and we can also use them as what as digital pins I want you guys to keep that in mind all right so uh see you in the next section where we're actually going to work we're going to work with these a pins with these pins that are exclusively analog pins you see these pins they're exclusively an analog all right so they're only analog pins so we're going to actually check them out and and for the first time in our lives we're actually going to use pin mode and set it up as an input so so far we've used PIN mode and set it as an input as you remember here all right so we actually as an output so we're going to set it up right here and use it as an input in the next section so um see you then right so let's continue and learn about analog pins all right so right here we've got these pins right here again marked let me just unplug my right here these pins that are marked with an A and that respective number next to them okay are the analog pin so let me again Focus here all right there we go it's focusing let me just go a that closer maybe even Zoom it better let's be better there we go see those eight pins that are marked with a number and an a an A and A number next to them those are called what analog pins okay I'm just zoom out for now all right so we're going to be working them so let me go over to my schem right here and let me just scr over to my screen and what I'm going to do here open this so let's set up our pin so right here I'm just going to say to pin mode again then I'm going to choose a random PIN I'm going to choose a pin A5 okay it's going to put this as what as an input okay when we're using these a penss we're going to use them as an input so far we've worked with digital pins and we've worked with pins that are analog and also uh digital those ones that are marked with a squiggly sign I have a DOT on them all right so far we've used them as a what as an output but right now we're going to use them as what for the first time we're going to use them as an input we're going to use some pins those pins as an input okay so one thing I did wrong right here is I do not use a variable again variables make our life very easy why not use them I'm just going to say read pin it will make more sense when I go further through this video all right so I'm just going to say it's read pen okay I'm not going to use the direct thing I'm just going to use a variable again I'm not going to use the direct value of it okay so once I'm done setting it up what do I need to do I need to use the analog read Command right analog there's something called analog read as you can see right here all right we have what an analog read command so far we used what analog right my time correct use analog right we also use digital right okay so for the first time in our lives instead of writing we're going to use what we're going to be using analog read okay to read okay so what does analog read do so basically so far what been doing was outputting voltages if you remember so output voltages right now what we going to do is we're going to read voltages we're going to read voltages all right okay so let's just do that right here so analog read and what you're going to put right here on the analog read is is the pen that you're going to be reading with okay read pin okay all right that's what we're going to be using to read our pin with okay so let me just turn on my Aro right here plug it in right here and then let's upload this code favor no upload provided all right let me go to my uh tools and then let me go to my port right here and select the conf port now let me upload it it's done compiling it's done uploading so finished uploading but how am I supposed to see the result you know when we were using um output pins when using output what we did is what we used LEDs to see the power and the voltage that they had remember right so we've been using LEDs to do what to see the voltage when they turned on we said it was what it was 5 volt if it was dimmer we said it was a lower voltage so we used LEDs to direct us to basically tell us and to basically show us that what our what our pins are outputting what our pins are outputting U voltage okay how do we do it when it's reversed around so far it was an output but how do we do it when we're using an input so to do that actually let me just bring uh something that is common and I think all of you know of if you're using computers is a mouse okay so a mouse is a what is it an input device or an output device it's an input device and basically what we do is we connect it to our computer again I'm just connect to our computer and when we move we what we do what we see something on our screen what is that what is that thing that we see on our screen it's a pointer okay so we see a pointer so an input device what do we expect now we expect is what to see the results to happen on the screen that's what we expect okay so to do that and to actually see something on our screen we're going to use something called serial monitors okay so we're going to use something called what serial monitors so we're going to do a serial. begin okay serial. begin and in this one you're GNA write your B rate so you might be wondering what is a b rate a b rate is the the speed at which it's basically the speed at which information is transferred okay I want you to think of it like that don't go further or don't go deeper as it mostly does not matter but to catch it just for the sake of knowing and for the sake of knowledge to catch it is it's what it's just the speed out which what the speed out which information is transferred from your computer to other devices okay that's just the thing you should be thinking of BS as okay serial du begin 96,000 I said it as 96,000 as it's the most popular B rate all right it's the most popular one okay so I just started my serial monitor right here and what I need to do is quite simple I need to say is serial. print so I wanted to print something for example let's say I wanted to print the number one okay just say we want to print the number one for now so let me upload it right here okay all right it's done compiling it's done uploading and you go to your tab right here where it says serial monitor I'm going to touch that okay can you see what it's going on it's said 96,000 bot as you can see it automatically set it up because why I did something wrong right here what did I do I said it says 9,600 po right here and I used 96,000 here I'm supposed to say 9,600 so let me upload it again you see that I'm getting an error message right here so for those of you who don't know is you can't run your you can't upload or verify your sketch without removing the serial monitor so you always have to turn it off before uh uploading or moving all right verifying your code so I have to always turn it off and I do that and let me just upload it right here there we go it's done compiling it's done uploading so always turn off your serial monitor uh when you're uploading your code let me just upload it right here can you see it it's uploading one at very fast speed look at it one one one one one you can see how fast it is look at how even the pointer is moving it's very fast okay so I just said is print one that's all I'm going to do it's basically like the print function that we use on U on um python okay all right so I wanted to print the value of this I wanted to print the value of this okay I just wanted to print the value of this let me just do that set it up and just turn off the semicolon right here first things first what what should I do I should what turn off the serial monitor okay just turn it off and you know what it's going too fast for me I'm just going to give it a delay so I want it to delay for what let it delay for maybe 500 milliseconds okay so basically half a second I just want it to delay for half a second because it's going too fast for me okay it's done compiling and it's done uploading so let me go back to my serial monitor right here and we're receiving that's very confusing isn't it I mean is it is this one 50 because it printed it out at very fast speed so is this 50 then is a 50 here or is it 55 or is this 5 554 are they together or what I can't see it until it uploads it right here okay this is very hard to keep up so what I'm going to do here is turn off the serial monitor right here okay I'm just going to do that and what I'm going to do right here is say print and add Ln at the very end what this does is basically it prints out everything at a new line okay so prints it out at a new line every print is is going to have its own what its own single line all right so with that in mind let me just upload it right here and let's see what happens to the serial monitor com for serial Port all right there you go it's working actually all right you see it it's just fluctuating seeing 321 receiving 280 273 256 255 okay okay okay this number does not make mostly sense does it I don't think it does so what I'm going to do is all right what I'm going to do is this so let me just try to do is well I'm just going to read off of the 5 volt voltage all right so what I'm going to do here is I have an analog pin right here okay I have this analog pin again what analog pin am I using for this I'm going to be using analog pin five let me just bring analog pin five right here I'm just connecting it right here okay analog pin five let me just make sure that I actually connect to analog pin 5 and that not connect to any other pin andl pin five okay let me just connect it here okay so let's just again upload this code it's already uploaded but I just I just uploaded again so that it restarts all right then we receive again these weird numbers because I still do not know what are these okay what they are I still do not know that so I'm receiving 1023 986 all right so we have to make something of these numbers Okay so so what I'm going to do right here okay is you know what this is supposed to read the voltage again as I told you guys it's supposed to read the voltage that is coming from what from our arome so let me go right here I have my A6 pin right here can you see it I have an A6 pin I have the 5vt pin right here but I am very very int I am very very confused should I connect this together or should I not I am really hesitant about the circuit should I connect A6 with the 5vt because if I do am my I might short the circuit if I short the circuit basically I might fry my ardino you know so I'm a bit hesitant on connecting them directly to connecting my pin right here with the 5vt because I'm not used to doing that we're used to what connecting the 5vt and then going through a resistance and then going to what to the gnd D all right if I'm correct so how do I do that then how do I check um you know I'm very hesitant about this U circuit right here I don't want to connect the A5 pin directly to the 5vt PIN cuz I'm a short circuit but I want to do it so that you know the answer it gives me is 5 Vol I want to check it so I'm a bit hesitant on this on this U circuit so rather than just you know doing this and hoping for the best it's better to do what again it's better to run a simulator so I'm just going to go to my screen right here turn on Chrome and go to simulator right here okay that's what I'm going to do I that makes my life a bit easier okay so again let me just go right right here and I have it right here all right let me just open this so I can assimilate it all right let's just check you know what happened here does something bad happen Okay so I have uh my analog pin here connected with the digital pin I want to change that to a 5V pin I want to see what happens with a 5V pin my 5V pin is right here there's my 5V pin okay and I have have my what my analog pin okay I have my analog pin how about instead of connecting it like this it's better how about I just connect them directly you know let me just turn both off and I'm going to do is five volt pin connected directly let's say to one of the anlock pins this case A5 let me just start the simulation here let's see what happens nothing happens so far nothing happened everything seems fine doesn't it so far seems fine nothing is going going on I mean let me just check my code right here is my code good put that right down I just did I set A5 to read I set A3 as a read pin I just want A5 to be a read pin I don't need this because I'm using the 5 volt again I don't need this I just need my serial you know serial top again 9,600 I already set that up all I need to do is what um say analog I said reader a variable reader right here set it to analog read pin I don't need that right now let me just copy this let me just go back let's just write it down as if uh the one that I already wrot down on the uh on the Aro ID okay so that's all I'm going to do so yeah I think that's my code for now let's startop my simulation right here so far nothing there's no um warning or anything okay all right what else could have possibly happen all right so I want want to go to my serial monitor right here oh there's a Serial monitor right here all right I keep getting this value 1023 1023 1023 1023 1023 again so so far um my uh simulator told me that it's fine to connect an Arduino a pin with a what with a 5vt pin did not say it's correct you know to put it together but like let's see what happens if I connect an aen while we're here let's just check what happens if I connect uh maybe a digal pin all right thereal pin maybe eight you see thereal pin eight to um to a 5V pin right here let's just say I want to connect to a 5vt pin what happens you what what could possibly happen um let me just start simulate simulation right here maybe let me start that before doing that though let me go on my code and let's just let's just write it to become High all right let me just do that okay I received 1023 again um going to get back to that okay but I just want to check again what's going to happen when I connect the digital pin with a with a five W pin so I'm just go pin mode and what I need to do is set up the digital pin 8 eight and say what as an output I want to use it as an output what else do I want to do one final thing I want to do is what I want to what I want it to be I'm just going to say is what eight said that to what let's see what happens let me start simulation o what happened saying okay this one has an error right here okay let me start right now now seems fine see that it seems fine there's no error coming from my uh simulator telling me you should not do this or something it seems fine because it does not make a full circuit but one thing that's not fine that's definitely not fine for example it's connecting the 5 volt p pin with the gnd pin let me just connect it directly 5V in the gnd let me just start the simulation right here if I do that might not tell you right here but what happens is basically what it's basically frying your Arin know LED so this does not tell me what it does not tell me if it's fine or not okay it just does not tell me that that it's not worrying me about U connecting it directly with u the 5vt the gnd because it's very dangerous to do that because again what I said is shorting is going to happen and basically what's going to happen it's basically going to fry oural so you see that it's fine but if I go to another maybe simulator if you search for another simulator right here it's going to say it's not right anyways so um let's go back to actually uh what it was so let me just go back to control Z let me just stop the simulation and let me just um get the 1023 right here the number 1023 okay let me just go back here okay we connected this directly there we go let me go back to my code let me just okay so let's start the simulation again what did I do right here I put a semicolon before this all right so let me start right now okay seems fine let me go to my serial monitor okay it says 1023 1023 1023 so I want to explain what this number is it's like the number that we used at zero and 20 255 on the analog right command we using 255 so let me just explain this right here let me just bring the paper and explain this right here okay so the same thing we did on U we basically did on the uh 255 to zero value when we were talking about uh the analog L right command Okay so look we have 1 we have 2 4 8 16 again to the power of 0 to the power of 1 this is to the^ of two this is to the^ of three and to the^ 4 is 16 and keeps going on okay we reach a point of 10 24 let just bring it right here 1024 this is what this is what this is 10 bits okay so we stopped at eight bits right here this was what 256 where we basically used for the analog right command but this extend this and can count to what up to 1024 okay to the power of 10 that's why we keep receiving 1023 why do we keep receiving 1023 we're receiving 5 volt right here because I connected uh the 5 volt with the what with the analog pin so I I expect a 5 volt so 5 volt is what 1023 why did we say 1023 instead of 1024 because we start counting from what from zero that's one thing you need to know so when you start counting from zero what happens it becomes 1023 just like 25 six right here we start counting from zero it's going to be up to what 255 right so 1024 is what 1024 it can store 1024 items but it can because we start counting from zero it's going to count to what count to 1023 okay so all right so right here we get 1023 basically meaning what 5 volt we receive 5 volt okay so that's that's what we basically are receiving how about if I just um remove this 5 Vol right here okay let me just remove this 5vt let me start the simulation right here all right let me just remove this 5vt I'm not going to connect the 5vt anymore so what I'm going to do is I remove the string between the 5 volt and A5 right here what I'm going to do is you know what I want it to go to gnd D I want to connect the g&d with the A5 let's just do that okay so let me start the simulation right here okay okay let me start simulation let me clear this one first let me clear the serial monitor let me just remove it and open it again I should be doing that I should fully remove it stop the simulation start it again let me go back to the serial monitor nothing's coming by as you can see right here nothing is coming by can you guys see that nothing is coming by right here they're trying to read the p in but nothing is coming by here we're trying to use E5 let me just set clear right here just to clear it up but uh nothing seems to be working so in this case let me just uh reload it I think it's better through that way and we go through these erors of the serial monitor uh when I was using the arino what I could have done is you know I could have done is what remove close the window right here I'm just going to do is clear it and I'm going to do is close the window right here I can do that but sometimes when the simulators again don't work because they don't fully mimic the physical world I going to have to reload it because again it happens okay let me go back to code right here and let's go back to our serial monitor we keep receiving zero when we connect to the g& D pin we keep receiving z0 z0 and zero like perfect pinpoint accuracy I'm talking 0 000000 can you can see that right when it's a 5vt we receive 1023 when it's at Z volt we receive what we receive zero okay so 1023 corresponds with what with 5 volt when we're reading it when you're writing when we're using the analog write command let me just again for you to remember the when we're using the analog right command 5vt corresponds with what 5vt corresponds with 255 the 5vt right here when we use analog read corresponds with what 1023 I know it might seem a bit odd that we're using you know two different you know bit systems here we're extending this to to the power of 10 or we're just using to the power of 8 uh for analog right it might be you know it might seem weird or stuff but it's just again convention this is something that arduinos people who built this uh decided upon I don't know why they decided upon this but as long as I'm concerned it's going to be again 1023 for analog read and it's going to be 255 for analog right okay that's all you need to know okay so uh now we've worked with what we've worked with analog pins but we've not worked with a physical arbino we've been using simulators okay so let's actually work out with a physical arino and actually add a bit of a Twist to it and make a good project so I'm going to introduce a new uh electrical equipment right here called a potentiometer right here if you look at it it's blue right here it's called the potentiometer it might be different depending on the kit you have so it might even be black might even be long but one thing you need to look for is three legs right here and an adjusting knob so you have a knob that you can use to adjust all right so you have the knob right here that you can turn that's the two things you need to look for in a potentiometer so might be different when it comes to yours when it comes to your kit so again check your uh check your label all right so check the label and check if it's a potential meter or not okay so what is a potential meter again before uh you know working with the component and stuff we need to learn the science behind it so let's check what a potential meter is okay so we have the simple circuit here and has a potential meter here and then it goes back to the negative terminal this the positive again again this is the negative the smaller one is the negative terminal okay so the potentiometer you can just think of it is what as a box that has two resistors here let's let's call this one R1 and R2 okay so R1 and R2 so just think of it as what is a big box that has two resistors okay so there's going to be what RT let's just say it's the total value of resistance here it's going to be what since it's connected in series it's going to be what we're going to directly add them up we're going to add them up directly so we're going to say R1 plus what R1 + R2 because they're connected what directly okay so that's all we're going to do RT is what R1 plus R2 so what does this let us do what does a potentiometer let us do why is why is that so that a potentiometer is very important than a you know why why is it different than a resistor think of it as a variable resistor so when you adjust the knob right here you can change the value of curve current the the value of volt that comes out of here okay so you can adjust it so that what you can adjust the resistance here so think of it as a what as a variable resistor okay so let's say right here I just put it all the way to the very end to the very left okay I'm just doing that right now I hit the left the very end I can't move it further than this let's say I put it right here what's going to happen is when I do that let me just draw it right here when I'm with the very very left R1 is going to have a value of what RT RT right here the total resistance okay and R2 is going to be what R2 is going to be zero again when I say zero right here I've told you guys that uh there's nothing called as a zero resistance it's just uh Theory okay so it's very very small that it's close to zero but it's definitely not zero okay I haven't told you guys that even these connecting wires that are not you know that don't serve as a resistor have what resistance so everything has a resistance even though it's what it's very very very low okay so in theory it's it's zero okay so with that in mind when what happens when I put it in the middle when I put the knob in the middle what's going to happen is what R1 is going to equal to what R2 which is going to be equal to what it's going to be equal to half of the total resistance half of what total resistance okay all right then what we're going to do is basically go to the very very right so what's going to happen so in this case what happens is R2 is going to be what R2 is going to be RT it's going to be equal to RT while R1 is going to be what it's going to equal to what to zero okay I just want you to keep that in mind okay so right here let me just turn this notification off okay there we go so right here we have this again voltage out again the voltage is going to be output right here so we got these let me just go closer right here focus on these so you see those two these are R1 and R2 they're connected to R1 and what R2 these the final ones right here okay the the first one and the last one they're connected to what to R1 and R2 and the middle one is connected to what the middle one is connected to V out this is going to be the voltage out okay so with that in mind let's just get started so let me just put put this potentiometer right here okay so again when you put the potentiometer let me just remove my uh let me unplug my arino right here we need to what we need to put it across we don't put it together we don't put the wires together again we just do it what across let me just put that across right here okay you need to again look like it's facing the front Okay so with that in mind what I'm going to do is connect it to a 5vt okay and we're going to use our analog pins to do what to read the voltage out of here okay so let me just do that right here let me just go on 5V right here connect to to the to the 5 ft okay let me just do that just go to the 5V right here can't see it all right there you go I got it right here I connected it to the 5V with the black wire and then what let me just connect the the the third one right here the third one the third leg the last one right here with the what with the G and D let me just connected with the G and D right here boom I did that and then finally I'm going to need an analog voltage again the voltage that I'm going to be reading off of I'm just going to put it in the middle in the middle pin right here for you to see it in the middle pin okay I'm going to put it at um A5 so I already have this code written is uh I reot it earlier so what I'm going to do is it's already uploaded so I'm just going to run it okay you guys can look on my screen if you guys uh remove the code or not but I already have okay so let me just upload it's already uploaded right here so let me go over to my screen right now and let's open our serial monitor let me go to my serial monitor right here let me just make this a bit taller just all right there we go maximize it it's 1023 it's outputting 1023 1023 1023 so let me just adjust it right now let me just adjust it a bit can you see it's going lower it's going lower lower lower right now let me just try to put it the middle roughly in the middle all right it's going lower right here just roughly in the middle a bit okay it's roughly in the middle right now I put it straight so it's roughly in the middle and then let me just adjust it until it goes to zero let me just adjust it all the way down let me just do that you see that we're changing the what the voltage value coming out right here can you see that we're going to zero we don't get a true zero right here but we get get something that's very close to zero what is going on is is we're getting a value it's like 0 point something and sometimes it rounds it up to one sometimes the rounds it down to what to zero okay so with that in mind something that actually can make this more interesting is what putting on an LED so what I'm going to do right here to put on this led actually make things interesting let me actually move this a bit because this is taking too much space let me just again move it to the very furthest right here that's all I'm going to do I'm not going to change anything because this going to take a lot of space let me just go and uh let me just go and put this as close as I can to the wires just takes a lot of space okay I have one space right here so I'm going to again connect the positive terminal of my uh of my LED right here to what to one of the uh to one of the resistors R1 or R2 whatever you want to pick I'm just going to connect that and then what and then I'm I'm going to connect the negative side of it to what to the g& D so I'm going to need to do that let me just do that okay let me just connect these two pins I'm not connecting the middle pin I'm connecting the positive the the one the the black one and what the red one okay I'm connecting those two let's see what happens when I try to adjust the knob right here let me just try to adjust the knob all right let me just do that it doesn't work why is that so one thing I need you to understand the potential meters is what RT is fixed okay RT is always fixed what is changing is always R1 or R2 the value of R1 or R2 is changing but RT is what it's always fixed okay so when I'm going through the whole resistance right here RT is what it's always fixed in potential meter right now my potential meter is what 10K ohms and it's going to be written on your uh it's going to be written on your potential meter or at least at the label that of how much uh resistance it has okay so it's going to be the total resistance minus 10,000 amps okay I want you just to know that but it's going to be reading for you all right so with that in mind if I just again run this over again it won't work so what I need to do is what I need to go to the middle so let me just do that how do I do that I connect the gnd D again to what the gnd D is the red pin if you remember is it the g& D is what the gnd D is connected to which pin let's just remember that the g&d is connected the red pin okay it's confusing me a bit because the red pin is supposed to be connected the 5vt uh as a standard and like the black pen is supposed to be connected to what the GMD that's a standard again again does not change anything but it's like a standard between electrical engineers but I just you know I rushed over it and just changed the color so it got me a bit confused all right so let me just connect the positive side to what the positive side to the middle pin so I'm just going to connect to the middle one and the negative side of the led to the what to the red one so let me just do that it's crossing over I don't want it to touch each other that would be bad don't want that to happen okay there we go now let me just go tighter right now trying try to go tighter right here right I think this is the one all right so now let's try to adjust it okay let's adjust our knob can you see it it's dimming slowly slowly slowly this looks beautiful especially when it's going slowly you see that we did that all right that's beautiful now looks nice but before finally actually finishing uh our project what we're going to do is what I want to look at the serial model right now it's outputting 231 231 some value let's just change this to what let's just change this something that makes more sense to us that has some something that is what that is a value to us again I don't want it to show to between 0o and 1023 I wanted to show what I wanted to show 0 to 5 volt so what I need to do right here it's quite simple I need to do some bit of math right here so what I'm going to do is what I'm going to say you know what let me just set up a value right here it's going to say in I'm G to say um calc value because I'm going to what calculate it so I'm just going to say calc value and what let me just set it to zero for now okay Cal value and what let me just uh let's there's a delay right here let me just go beneath that and I need to do is what just set up the Cal value right here Al is set to what I'm going to say is what it's going to be what it's going to be 5 / 1023 you're going to divide that then you're going to what multiply by what I'm going to multiply by what I'm going to multiply by the analog read wait I got that wrong analog read and I'm GNA say okay just multiply right here and I'm just going to say Cal F okay there we go all right so what I'm going to do is upload it right now and let's see what happens so let me just upload it right now again my serial monitor is it off right there we go is my serial monitor off all right I turned it off right here all right I turned it on right now just turned it on again make sure that your serial monitor is off every time okay I get z0 z0 z0 0o then let adjust it getting zeros let me just adjust it the other side we're getting a zero even though this is adjusting you can see that we're getting definitely more than zero it's saying z0 0 z0 so the problem here is let me just show you what I did the problem here is what I'm using integers so right here it's going to bring what 5 ID 1023 is going to give us what it's going to give us a decimal so what happens is it's going to what it's going to value it's going to what it's going to round it down to zero because if you just think of it let me just divide 5 by 1023 let me just divide 5 by 1023 let me just bring my calculator right here let me just bring my calculator right here I'm just turning out my calculator let me just divide 5 by 1023 1023 it's almost what it's almost zero and it's what it's rounding it it's rounding it to what it's rounding it to zero so any number multiplied by zero coming from the analog it's going to always read what it's going to always read read zero so what do we need to do we need to set it as what as decimals so I go right here and what I'm going to do is set a point next to it all right so I'm going to set a point next to it and you can say 5.0 or just a point next to it it doesn't really matter it's up to you so I'm going to set a point next to it and one final thing I need to do is what I need to go to calc Val right here and I'm not going to to set it to integers I'm going to set it to float basically float means what basically float means um float means uh decimals all right so you can just set it up without actually uh giving it a value it's up to you let me just upload it right now okay and it should be working okay it's done compiling okay should be done uploading by now let me open my serial monitor right here all right we're starting to receive real numbers here okay we're receiving 4.7 4.5 right here 4.2 we're now receiving full 5 volts you know you might be wondering why if I remove this led right now we're almost going to receive 5 volts you see that as soon as I remove the LED we get 5 volts because we're you our LED is what our LED is using up some of the voltage right here that's why okay so it's using some of the what the voltage if I remove it right now if I remove this led right now it's going to be what let me just remove it for now it's going to be giving me 5 volt 5 volt 5 volt 5 volt can you see that as soon as I put it back in though I think this right here as soon as I put it back in it's going to going to be giving me 4.8 because what it's going to be using Z what2 volt right here our LED is using what to 0.2 volt of the value okay so let's just adjust it again just to check it out adjust it adjust it more adjust it again adjust it almost off right now and there you have it and that's it for uh this project so I think we build something with a potential meter I think it's one of this uh higher end of projects that are actually nice so okay so I did not change my circuit here it's the same from the previous one but we're going to add something called buzzers so if you look closely right now let bring it close enough these are called buzzers and we're going to use them to basically create sound so we're just going to change electrical energy to what to sound energy basically by what by vibrating so again before working with these buzzers let's go in depth and try to understand what they do so let's just have a rough idea of what buzzers are okay so if you look close enough again this are called buzzers if you look close enough they're not the same thing if you look at top they might seem like the same thing but if you look U at the bottom there's a black one right here okay and there's a one where you can see the circuit okay so let's just go here and try to understand what they are so the one marked with a black one is a what is called an active buzzer okay an active buzzer and the one that does not have any board any uh bottom on it and where you can see the uh where you can see the components right here is what is called a passive buzzer okay so I want you to understand the difference between these two so both of them are used to create sounds but it's going to be different for both of them so let's go right here and let me just explain what an active buzzer is okay just do that so an active buzzer what it basically does is what it needs DC voltage it takes DC voltage and what basically happens is there if you look inside if you just pry it up open there's a cone that vibrates okay there's a cone that vibrates back and forth back and forth okay there's a cone that what that vibrates back and forth and basically what creates Sound by vibration so let's just do that so I have my again circuit from the previous uh lesson so what I'm going to do is I'm not going to touch this one I'm not going to touch any of these I'm just going to give it a new space and one important thing you need to understand is this thing if you look at it it has a plus sign okay so not only that too but even there's a difference in what there's a difference in their what in the length can you see that this one is longer the plus sign is what is longer just like what just like when we were using what LEDs so keep that in mind both of them have what both of them have a plus sign both of them have a plus sign and the plus sign what leg is longer okay so let's go back to our active buzzer right here all I need to do is put the plus sign around here and what I'm going to do is connect it to the 5vt so let me just go the 5V right here there's the 5vt and I'm just going to connect to the longer side of it or basically the positive side that's all I'm going to do okay and let me bring another wire right here let's get another wire I sure this is a very short wire let me get a longer one let me get a longer wire right here all of them are short today I have to go closer if not all of them are short I don't have any longer wires left I've used all of my longer runners okay so if I have a short one what I'm going to do is go through this side let me just go back to this side okay and let me just take this 5 volt right here and take it put it right here got the gnd D the ground pin this going to I'm going to connect the negative side to what the gnd D so let me just do that that's the gnd D right here and it starts to make what can you hear that starts to make what sound directly as I plug it in so okay that's what a an active buzzer does okay so let me just bring this one the passive buzzer okay when I'm using a passive buzzer one thing that's necessary to do is what the difference that comes here is I need to use AC basically I need to use what AC circuit for this one I've just directly used what 5vt when you look at the Arduino 5vt right here the 5vt PIN it directly outputs 5 volt DC basically what direct current I'm going to come back to this and actually compare and contrast them but it use what direct current okay so for this one we're going to use AC current alternative current okay so let me just uh remove my uh active buzzer here this is my active buzzer again the one with the black one let me just remove it let me just remove the wires that I used for the active buzzer so that it does not get too many see just do that okay and now what I'm going to do right here I have again my passive buzzer let me just set it up let me just unplug my Arduino now let me just go back closer so you can actually see it there's my uh passive I'm just going to put it right there the same spot actually I need to I need my gnd D pin connect it to here my gnd D cannot see it all right there we go g& D pin connected to the negative side for the other leg just connected here and the positive side I'm going to be using what those digital pins that are marked with a what with a squiggly sign those ones that I said that are that behave both as a digital pin and also as a what as an analog pin okay so we're going to work with those let me just put it a digital pin n okay digital pin n because it what it has what if you look closely again it has what has a DOT sign wait let me just bring it close enough so that it focuses let me just actually zoom in more you see that it has a DOT sign right there so we're going to use those pins again that I mentioned that the ones that I used for what for analog right right now let me just zoom out okay zoomed out okay so that's what I'm going to do so let me go over to my screen right now and actually write down some code so let me just uh remove this right now remove this code because I have a need it right now we can write it now if you need to again okay so what I'm going to do is what we're going to need additional pin so I'm can say is what I'm going to need the additional pin n so I'm going to say what what is this passive Buzz just going to say passive Buzz it's G to be what I'm going to set it thereal pin n okay all I need to do is what after set it up going to say passive was set it to what as an output there we go then afterwards what I need to do I'm going to need to do is what use the analog right command and again use passive again buzz and then what then let me just set it to whatever I want to let's just say I want to set it to three okay so let me just set it to three let me just upload this right now it's don't comp compiling oh we cannot upload it because what we have not plugged our Arduino let me just do that right here let me just do that let me just remove the paper for now I'm going to go with the explanation after we work with it a bit okay let's just upload it St compiling okay it's not uploading but we can't hear anything can we I cannot hear anything is everything all right let me just again check my pins okay there's still pin n is here there we go let me just stop it for let me just stop it for a second uh you might not hear it as very uh you might not hear it as strongest the active buzzer because I set it to what I set it to three because it's going to be receiving less what less electricity it's going to be receiving less current okay let just do that again hopefully you can hear it if not let me just again increase the value here just put three just increase it to let's just say 20 for now just say 20 let me just again put back what distal pin n back again to good spot now it's louder now it's louder let's raise it to a higher value let's just say 40 or 50 we just set it to 50 I'm this upload it right now it's done compiling it's done uploading let me put it back right here now we can hear it louder all right so let's make it actually do something interesting is we do is put what a delay on it right so we're just going to set it on and off on and on on and off because it's going to sound better that way so I'm me just save delay right here analog right what passive Buzz to set it to zero right here and give it a delay again okay so one thing I did not do right here is set up what how much I want to set it to be so let just say again 5 milliseconds again I'm saying 5 milliseconds and let's upload it again let me just put it back right here a de butt can you hear it all right let's just set this maybe to delay what maybe to delay uh how about 10 just to say we want a longer delay all right we've experimented with the the passive buzzer and the active buzzer and one thing the passive buzzer you know is capable of is what we can turn it off and turn it on can you that can you see that you can turn it on and off as as we did right here we turn this to what to zero basically what turning it off at line 14 we basically what turn off we did as what turn off buzzer that's what we did right here what did we do we turn on buzzer but we couldn't do that using what using an active buzzer why is that so why is that so we can't do that using an active buzzer why is that so so um the big thing here is uh when using an active buzzer is what why couldn't we do that well it's because what 5 volt is always what 5 volt 5 volt always outputs what 5 volt okay so 5 volt always outut what outputs what 5 volt that's why it cannot you know go on and off that's why we cannot you know turn on off turn on off on off we cannot we cannot do it using a five volt but we can definitely do it using a distal pin we can definitely do it using a St P um okay so with that in mind let me just again actually so with that in mind actually what I'm going to do is going to be working with these potential meters before doing that we're going to have to go again with but we we have to go behind signs here so we're going to go to the signs so uh let's do that okay so why does a passive buzzer you know require AC circuit and why does a active buzzer require uh why does an active buzzer require a DC circuit a passive buzzer requires AC circuit and an active buzer requires a DC circuit why is that so well why is that so so in a passive buzzer okay we use AC circuit let me just bring a passive buzzer right here we use AC circuit because what because there's something called a vibration cone a vibration cone what it basically does is what it vibrates to create separate okay so the vibration cone what in an AC circuit what goes back and forth back and forth so one thing I want you to think of on AC circuit is what let bring this right here you've I think most likely you've heard the term AC circuit and youve most likely know this graph it goes up and down up and down when you look at a DC circuit it's what it's straight it goes what it goes one way this goes what this goes back and forth this goes back and forth basically what basically vibrating just think of it back and forth back and forth they very fast beats basically what vibrating basically when it vibrates what happens it creates sound okay so when you think of um uh uh uh direct circuit right here a TC circuit right here you might be wondering then how does a how does an active buzzer work then because it receives what it receives an active buzzer receives what an active buzzer receives DC circuit so when it comes towards a DC circuit what happens is when it comes to an active buzzer what happens is uh the difference in component here is that it uses something called electromagnetic uh electromagnetic all right Spectrum so what I use is what EMR so what happens is basically let me just explain this in a simple term not get into too much detail so what basically happens is this okay let me just bring the my sharp right here basically happens is this so you see this let's just say there's a magnet right here okay and there's something it's attracted to right here okay there's a magnet here and there's something it's attractive to so when it's on what happens is what it goes attractive to it it's attractive to it it goes go right here when it's off what happens is what this magnet is repelled okay this magnet repels okay so you see that it goes on and off so basically what when it goes on and off at very fast speeds what happens when it goes on and off and on and off what happens even using a DC circuit what happens what happens is it moves what back and forth the vibration coin moves what back and forth back and forth back and forth okay so that's the whole essential thing there's a vibration cone and it's moving what back and forth to create what vibr okay with that in mind actually let me just go right here I have my uh uh active buzzer right now let me just go over to my active buzzer what I'm going to do is quite simple I just want to create something that adjusts the volume so let's just use a potential meter right here so let me just go back to my uh buzzer again the positive side is right here so what I'm going to do is let me just bring my connecting wire and and what I'm going to do is I'm going to use this middle pin right now the V out of the potential meter that we mentioned earlier I'm just going to use this as my main terminal okay because then I can do what I can adjust the voltage that comes out okay I'm just going to do that and I need the gnd D pin so obviously I'm just going to take this gnd D pin from here and I'm going to put it at what at the end of the circuit let me just do that now it's supposed to work all right one thing I did not do is what uh right what did I not do the black one is supposed to be connected to what to 5 Vol think it's connected to 5 Vol is it connected to 5 Vol all right so one thing I did is what I forgot about the potential meter it's not what it has to come from one end to the other end let me just again if uh necessary let me just draw the potential meter again flip the page right now and as I told you guys let me just try to draw the circuit here okay we have the battery 5 volt have the potential meters is what a box that has what two resistors connected in what in series and in the middle we have what something that's going to Output our voltage this one is like the what the white pen in this case V output and we have what afterwards we have our buzzer that needs a positive side okay a buzzer and then it has a negative side you just put it with a circle on top that has a negative side and then what we connected to what the negative side basically the what the G and so what one thing that I not do here is what connect the R2 the R2 is right here I did not connect it I just jumped it so what I need to do is right like this so let me go back right here the V output let it stay right here that makes sense doesn't it so you know what I'm just going to put the V up right here okay then what I'm going to need another wire to extend it just do that okay all righty about to extend it there you go we extended so we extended it on the what on the white pin basically what the middle okay all right so let me just try to adjust it a bit I don't know if you can hear me but let me just try to adjust it a bit okay let me just try to adjust it okay I connected what the white pin I extended it to what to the red pin if you can see right here the white pin is the one the V out is extended to what the positive side of the what the positive side of the buzzer I'm using a what an active buzzer again let me just try to you know use it as a turning knob basically use it as a volume adjuster so what happens is you can barely hear anything at the middle or at the start and then you can hear something at the what at the very very very end okay when I put it to the very end okay basically when it's what but it's receiving the maximum voltage basically almost 5 volt it's receiving the maximum voltage you see it doesn't make any sound when I turn it all the way so obviously for this case do we need what we need a passive buzzer so let's just try doing that with a passive buzzer so instead of using what instead of using the 5vt pin again I need to take it out of the 5vt pin the 5vt pins connect to what this one and I'm going to be using digital what pin n instead okay just going to be using distal pin nine there we go then I'm just going to have my passive buzzer here the positive and the negative side again marked okay now we should have what we should have a a voice adjustment so let me again what I'm going to do is right now I'm just going to change it hopefully you can hear it now I'm just going to go silent and let's see the volume change can you hear it's not the smoothest it's not the smoothest change but definitely you can notice what the change in volume and it just changes all right let me just go right here and just give it More Voltage right now I'm giving it maximum of 50 let me just give it 255 which is the maximum value let me just give it a maximum value right now okay so now let's just adjust it again from here here can you hear it now it's one it's basically the potential meter is what we're using it as an adjuster all right so again potential meter we use it as what as an as an adjustment basically as a adjuster for what for the amount of voltage that comes out basically the current the voltage that comes out okay so we used our buzzers right now we used the um passive buzzer we have the active buzzer here we're not using it we're using the passive buzzer right now so we made this simple project okay so now we learned about what we learned about these buzzers and how to make really really good songs with really good sent with all right so even then too if you actually let me go to my screen right now let's make this a bit more interesting than it is so let me go over to my screen right now okay I don't need this all these wires right now let me just remove them I don't need my potentiometer right now let me just remove them okay so let me just go to my Chrome right now and if you go right here let me just say buzzer buzzer Arduino sound code it'll just go for code okay all right let's try to find a good code sound all right so there're going to be lots and lots of uh play Melody using the tone function right here let me just again let me just try to open this but what you can do what I'm going to give you as a homework is what what I'm going to give you as a homework is try to find all right try to find these Arduino codes again I use a buzzer you can see that right there we're using a buzzer right now right now I don't know what Buzz are we using I don't know if you're connected to a pin or a 5vt the image is not the best all right let me just go here okay there we go we're connected to pin 8 and gnd D okay all right and there's the there's the code right here all I need to do is what let me just copy the code right here and it has a library I need to include that and I'm actually going to see how to even include libraries right now so let me just copy all of this okay I'm copying all of it on YouTube all right there we go no me to repeat melody or whatever just copy this right now let just put this again paste this fully and one thing I need to do is what install a library okay there's a word manager you go right here and there's a library manager so let me filter my search I'm just going to say pitches image okay this says micro gameer just go and try to even run the code before uh including the varet it says what there's nothing called pitches. okay so let me just try to Google it right here what a pitches. is there are definitely lots of notes as you can see right here let me just go to U just. Ed there we go yeah we're getting to it GitHub page right now it just. Ed and I'm trying to include it as our uh there we go so I'm trying to include in our library right now I'm trying to include it in our library as you can see right now trying to search for hitch studed okay pites stedge just do that so again do it yourself again try to go through problems and do it yourself okay let me just install this because it's the only thing that's coming here okay let me just install this and let's try to verify our code even then to if it actually works all right it says there's nothing as in this directory no file in this directory okay pct. Edge there's nothing in this directory that's what it's basically saying so what you need to do in this case is basically simple okay so what I do in this case is just go to GitHub or any other documentation and ask them the simple question okay I don't know how to you know include libraries in C++ because I'm mainly used it so all right let's just go here my sketch cing the following error but just do it's not enough okay refering try to read one leads me this link right now this leaves me this link and and doesn't seem to go any further okay then how do we do it how do we go and add the Library store Arduino because I used to know this but over time I think I forgot about it all right pit still age does not seem to be working all right so let's try to use something that does not have any library but one thing I'm going to go over this again how to use libraries and stuff in the future all right how to install pitches. edge audio let's just go here there's an Arduino form and how to install it there's an Arduino documentation of what installing libraries right here pleas start Ed is a part of all right Z to and sign up all right so it's telling me to do what this part of what a sketch not a library an example of this is official 0.2 digital sketch that comes with the what with the rwo ID all right it's leading me towards this so again I'm just we're just running to what we're running towards the problem again the same problem again seems that we can't Sol it right now I'm going need to solve it later on okay let me just check the installing libraries documentation again I'm trying to U do this together with you guys is what happens is uh with uh when it comes to courses is it just seems easy when somebody else does at end we don't it doesn't seem that you're going through a problem we are everybody does okay all right so let me just go to again Library manager let me just do that so all right let me just go to sketch include library and manage libraries all right let just do that sketch um there say some clode library right now and say manage libraries right now okay you should open the tab right now just to get go again just to show you to you guys um manage libraries okay there we go just let me do the same thing pitches pitch just show me so it does not have a good documentation because if it did it's going to show me uh basically how to even install it you see that at adult zip Library it can do that so basically what I need to do is what download this pct. Ed right now that's what it's basically telling me to that's to download this you it basally this code download this and run it so let's just try to find something else that actually does not require you to do what to use this pitches thingy okay so let's just say buzzer arino sound code again let's just try to find it this is part of programming but you cannot find the things you actually want okay let me just say code and just say song song code see that play parrots at the caribbe and theme song on Arduino there are definitely lots and lots of great YouTube videos again to actually make a there we go Arduino and a buzzer songs for Arduino let's just try this one all right there we go let's just see the component again we have the gnd and we connected to pin nine right here okay that makes sense you have to include pitches again n you have to do that you can using this Library okay include Library add. zip Library all right all right there we go add a zip library but we do we do what we definitely need pictures. Edge what we need to download it as far as I'm concerned right now we need to what picture. Edge I need to find the library and download the zip I'm just go to pct. Edge right now you find the GitHub about it all right there we go pictures. edge I'm just going to download this right now let me just do that I'm just going to call this pitch. Edge because it makes more sense pites edge. siip just call it that okay that should be better isn't it better right now okay so let me just do that import that let's try that let me just import it uh how I do that I go back to this tab it's showing me how how to import it so okay importing a zip Library sketch include library at libraries let's just do that so let me go right here let's go tools no actually let's go to sketch and let's include library and then add don't zip libraries it's not available in the library manager it's not available in the public library but just Edge don't zip let me just try to do that it's processing it and it's installed it so I think my question should be working now hopefully it is okay it's done compiling so hopefully now it's going to work let me just upload it okay it's done compiling so that's nice okay Melody can you see that all right so we used our library manager right here but one thing we actually need is what it does not include what pen I use for this you know that's the problem right here the problem I have right here is what does not tell me what pen I'm supposed to use does it does it even set up a pin mode I don't think it does didn't I think in this case we're going to be using an active buzzer here because we're not setting up any pin mode and all that for uh for uh for a passive buzzer so we're just going to be using what I'm going to assume we're going to be using an active buzzer here that makes more sense so let me just connect the 5 volt right here connect the 5vt let just put it right here and we have the gnd D let me just again connect the gnd D right here it's a bit harder when you're filming to actually get the right pin let just go over here g& D got it okay I think this how it's supposed to work let me just make sure again I got the 5 volt and then not get the wrong PIN I think I did get the wrong PIN still getting the same thing all right so we're still getting the same thing I could possibly probably be right now I was trying to find another code because this one does not make any sense it doesn't at least we imported what the pict just. edip so should have been actually better okay so this one is horrible or maybe I did not read what I did not read the full documentation what did it say I have to connect it to What specifically told me what to connect it to what pin eight can you see that specifically told me to connect to what to pin8 so I need to remove this active buzzer again I don't know read the whole thing that's why I was rushing again to finish this video that's my problem right now but again it happens I just wanted to show you guys okay actually I did not know anything about adding libraries towards uh C++ or Arduino but I just wanted to show you guys the process of learning okay me and myself getting into bit of a trouble right here okay so we need pin eight it's hard to actually get the pin eight right now when you're here's pin eight all right I think it's this one I think I'm supposed to be doing this pin eight all right the gnd d uh I uploaded right sure if I uploaded or not just to make sure right now okay start compiling can you hear it let me just upload it again okay that's a nice tone right now okay how about I just want to run this again and again and again and again it's just running one more time have the what if I run this in the right here and just set it in the loop because I just want to run it again again and again and again that's what I want to do want to run it on the loop right here they'll before U Finish here I'm just going to just get a delay before you know writing the tone over and over again I'm just going to get a delay if maybe 10 seconds it's going to make it better I don't know if it's going to ruin the code we're just going to see it right now all right all right so this was a bit of a long one right now I don't think you can see the buzzer right here it because again I just moved moved it around but I don't think it matters again I just connected it to what to pin eight right here okay connected this one to pin8 and I connected this one to what the gnd D that's all I did this is connected to what to pin8 as in the image it's connected to what to pin eight it's just my uh it's because that my uh my wire isn't that long here you go you can hear it again there we go so I guess that's it for uh today uh yeah so actually see you in the next section this was a bit of a long one and really sorry by the way for um if you guys did not see the uh the pins I tried to tell you guys where I connected it to and but again this just happened because again my wire isn't that long and I have to pull it really hard to actually bring it here okay anyways uh see you in the next section okay so in this section we're going to discuss about uh photo resistors and termers okay so let's bring something that is familiar with you guys resistors obviously we use them to do what to limit the amount of current that is coming in so that it does not basically what ruin our components okay so right here we're going to learn about these special type of uh resistors so let me bring them right here this is a photo resistor and a therm thermistor looks something like this let me bring this close enough so that you can see see them for yourself so when you're looking for a photo photo resistor what you're going to be looking for is this quickly lines right here that goes like this like this like this okay you're going to be looking for those when you're looking for a photo resistor and just put that next to its nameee and when you're looking for a therm resistor you're going to be looking for these round headed again they can be green they can come in black but again always read your labels to make sure uh what you have right here okay so always make sure because they look close to something called uh ceramic capacitors okay so just keep that in mind let me just put this back to its place okay now let me try to explain what these are okay so these are as I said again they're types of what resistors they're some sort of type of resistors they have the ending of ister okay so there are different types of resistor so when it comes to a photo resistor when it comes to the photo resistor one thing you need to understand is it is a type of resistor where the resistance value changes okay depending on light obviously the name photo the beginning of photo indicates something that has to do with what with light just like how we use photosynthesis has to do something with what with what with the light so what resistors are what these are types of resistors in which the resistance value changes according to light this happens so that because we use um a special material all right on the top use a special material which changes its resistance again corresponding to what corresponding to light all right so one good analogy of this would be something we've worked with in the previous project which is going to be uh it's going to be a potential meter right here let me just bring it closer the potential meter we just worked in the past few sections so potentiometer what happens how do we change its resistance it's a variable resistor as I said again how do we change its resistance we just change the knob just like this when it comes to the photo resistor what do we do we Chang the light we Chang the value of light so we change the light again we go dimmer and brighter and it's going to change our what our resistance okay just keep that in mind all right when it comes to our therm resistors the name thermy gives it away it is related to what something that has to do with what with temperature okay something that has to do with what with temperature so when it comes to therm resistors basically just like how photo resistors again change their resistance value according to what according to light just like a photo resist just change their value according to light these therm resistors let me just go closer again these therm resistors change their value according to what according to temperature okay according to what according to temperature just keep that both in mind okay so now we start I think uh working with our photo resistor here let's just keep our term resistor on the side here because they're very familiar that's why I just chose to teach them together but let's work with our photo resistor first okay so let me just get this out of the way bring my Arduino here have my photo resistor and what I'm going to do is basically connect a simple 5vt circuit so just how we used to use an LED and a resistor instead of using a resistor we're going to be using what we're going to be using a photo resistor this time okay let me just turn off my light here let just turn it off turn off my adreno bring the ardeno closer so we can focus on what we're doing right now okay there we go I'm going to connect the 5 VI right here the 5vt connected to the 5vt pin the red the red wire all right nice now what am I going to do going to bring it here move it to here okay then I'm going to have my resistance again here I'm going to put it across okay when it comes to resistance again it does not matter which leg you put it through obviously this matters in LEDs but when it comes to anything type of resistance it doesn't matter which leg you put through first okay the same comes to poten the potential meters here you can put what the first leg or the last leg it doesn't really matter what matters is the middle leg obviously it's going to be the one with the V out so obviously the middle leg is the important one that you actually don't want to mess up but you can just choose between these two you can just put it in the g& D or this other side on the 5vt doesn't really matter okay let me just put that here focus on it again all right let me get my LED my handy LED right here got my LED now I'm going to connect one leg of the photo resistor here to the what to the LED let me just do that just focus here so you can see it better there we go now you can see it way better all right and then what do I need my gnd okay I'm just bring the black wire here again connect this to the gnd where's the gnd at it's right here just connected the gnd pin or the negative terminal let me bring this across here right and let's just put it back here to the other side of the what the L D okay we just did that okay we just did that but there's something wrong with this circuit I mean it seems fine when you look at it because as far as I'm concerned what did we do let's just recap on it what did we do we used uino as a 5vt output because we connected Thea to the 5vt and then what else did we do afterwards we went to our what let me just bring this aside here what did we do we brought our resistor here this case it's a variable resistor and you just indicated by this by this symbol variable resistor is indicated by this symbol basically changes what it's resistors it's resistors value it's resistance value changes according to a condition okay in this case what is going to be the condition of light all right then we have our LED our handy LED how do we write that down we go like this then we go back to our negative terminal one thing I did wrong here is what this is the negative terminal the negative terminal is what the the smallest side so I have to put a negative here and I have to make this the positive I have to make it the bigger one because obviously why because that the big one is the positive the bigger line and the smaller line is what negative okay let me just put that and again let me just correct this this goes big small and there's a small one here just put this to Big all right there we go I'm just correcting this anyways what basically happens here is what we have the 5vt output we have our resistor we have our LED this seems like a normal you know a simple 5vt circuit again this should be working and there's nothing wrong with it as far as I'm concerned it looks perfectly neat instead of using our normal resistor right here we just used some sort of resistance instead of using our nor noral resistor that we have here instead of using that we basically did what instead of using our normal resistors we basically used what a photo resistor which we said is what it's a type of what is a type of resistor but the problem that lies here is that this photo resistor the value changes over what over light so right here I have a bright environment all right I have a bright environment all right so so how am I supposed to be sure how am I supposed to be Reliant that the photo resistor you know doesn't have a small resistance value because we said the resistance value changes how am I supposed to be sure that the resistance value is not very very small how am I supposed to be sure right because one thing you need to know about photo resistance right now is as the light increases okay as the light increases the resistance decreases and the out then the opposite goes through too as the light decreases the resistance on um on the photo resistors increase okay I want you to keep that in mind so right here I'm in a very very bright environment I have two lights set up just for this course okay so how am I supposed to be sure that you know this does not what this basically does not have a very little amount of resistance value that what we're going to have too much current and it's going to frog our LED how am I supposed to be sure of that so to be sure to be exactly sure in this case we're going to have to put a backup resistor basically in case if we have a very very little amount of resistance in case we have that we're going to need a resistance that does not change okay so what I need is what what I need is a normal resistor again just to back me up in this case because if this resistance value just changes to let's say a value of let's say resistance value goes to what goes to very little numbers let's even 0.002 okay let just say 0.2 ohms okay let see even it goes there if it goes there let's just calculate the amount of current that goes here so current is what the voltage over resistance the voltage is what the voltage is five it's going to be divided by 0.002 okay there's the current if I just do that if I just do the simple math here here and this is going to be zero multiply this all both of them by thousand okay and it's going to be over two 50 over two is going to be 25 we're going to be receiving 2,500 amp it might not seem you know very big it seems like a big number but it might not seem you know too big because we don't we're not you know relatively what we're not contrasting it with uh what we know all right this is a big number this is a very very big number but put it to the light and to see how big of a number it is let's just use our normal calculation right we have 5 Vol and what is our resistance that we use 300 what 330 if I just run this on my computer right here let me just say 5 / by 330 it's almost the current that we receive is almost 016 amp which is almost how much if you just put this to light again how much almost 16 milliamps milliamp can you see it 16 milliamp if the number goes too low what happens we receive an what an excess amount of current basically what it's going to fry our LED if not even our Arduino might even fry our Arduino because of how big of a number it is okay how big of current we're receiving so just to make sure again we're going to need what a resistor that that is not variable that doesn't change we need what a normal resistor all right so in this case I'm just going to put what a normal resistance as a backup all right so let me just unplug this and connect my just bring this here let me connect the other leg of the U the sorry photo resistor right here towards the other leg of the resistor my normal resistor all right there we go they're connected okay once I'm done connecting them what do I need I need my LED again always check for the positive side the longer one the longer side of it I found it I'm just going to put it here all right and I'm going to need my what my g& D pen let me just use my what my gnd D to the other side of the LED let me just use my gnd d right here all right now it's ready now let me just turn it on let's do that turn it on right here okay everything seems to be working fine let me just everything seems to be working F right now it does again we're not going to be coding anything on the ardino because we just going to be using what the 5 volt so now I want to change what the value of this uh this photo resistor the value of the resistance again right now I'm using what two bright lights right here I have one light right here on the left I have one right to the right so it's very bright right now so clearly the resistance value again what happens let me just bring my here if the light goes up the resistance value goes down so in this case the resistance goes down let's say theoretically it goes down to very very small number let's even say to almost zero okay let's just say zero so what basically happens here is what we're going to have our 220 um resistor it's going to be obviously regulating what comes from um the photo resistor because in this case we're using what we're going to have a very very small number almost close to what almost close to zero okay so light up light is up right here so the resistance values down that's why lots of current is Flowing so what so our LED is what our LED is what our LED is brighter okay so let me just try to decrease the light and see the resistance value come up basically what basically dimming our LED we'll just do that so let me just go here turned off one light turned off both lights it's getting dimmer let me just go and even turned off the curtains let me just fully turn them off now we are in a very dark environment except for the LED that's sliding up right here the Arduino built-in LED let me just block it for now okay by my hand you can see how dim it just got you can barely see the red light right here the red light right here I just dimmed it out okay you can see that it's what it's very very dim let me just turn on the light right now both lights all right here we go you can just see that what it was dim like a few seconds ago and now it's bright okay so this is one thing you need to keep in mind when working with what with photo resistors one thing you always keep in mind is what photo resistors are not always Reliant they're not what they're not always Reliant because why because again the resistance value always changes by light okay so where do you think can we use these photo resistors one of the applications of photo resistors would be what especially when we're using Street lamps basically there are going to be what there are going to be times where again street lights again will turn on and off automatically again no manual configuration you you don't need to turn it on or off it's going to what it's going to detect the amount of light that is coming out from the Sun and if it's very very little what's going to happen again the resistance value is going to be very high it's going to record it and then then afterwards it's going to what turn it on it's going to basically what it's going to turn it on automatically so we can use Photo resistors for what for self for selft turning on and off lights okay so we're going to use them for what for smart lights okay so we worked with the photo resistor right here let's work with a bit on the the ther therm that we just mentioned earlier okay let me just unplug all of this take this off all of it there we go there we go okay just did that and now let's bring my right here my valuable barister and let's try to do the same thing so again let's connect it almost the same circuit okay let's try to do that all right I have my 5 volt right here connected here then I've got my thermister again I can put which leg I want to because nobody's going to force me again because it's not what it's not important which leg you put it in let me just go back here get this straight actually put it here just put it here let me get it closer I'm going to tell you why in a minute just going to put it closer to the Arduino because I'm going to need this piece right here okay then afterwards what I want to do is use my normal again my normal handy again normal resistor why is that so because again the temperature value is going to decide if the resistance goes low or high okay so it's going to be very very important for me to use what to use this so that I don't fry my LED okay I did that now what I'm going to do is what connect it to this Edge right here the let just get this straight the Arduino the normal resistor okaya all right there we go it's connected like this I can just unplug my adino right here there we go got it closer so you can have a better look of it then I have my gnd D there we go connect the gnd to the gnd D pin let me just do that all right now what do I need to do plug in my uino and you can see it's lighing up a bit can you see it so basically temperature here is what we cannot know yet first thing now we have to do is let me just bring another paper right here and try to explain what is going on okay so let me try to explain uh what is going on right here let just get this out of the way for now to the edge put my photo resistor right here right bring my Sharpie right here and try to explain what's going on so when it comes to thermistors as we said earlier what did I say I said that it's relevant to one it's going to depend on temperature okay so there's something called NTC and PTC okay so when it came to photo resistors what did we say we said directly if the light is what if the light goes up the resistance value goes down okay if the light goes down the resistance value goes up of the photo resistor that's what we said for photo resistors it was what it was quite direct and straightforward but when it comes towards uh uh when it comes towards thermister there's something called ntc's and uh ptcs n stands for negative okay n stands for negative T stands for temperature Okay C stands for what C stands for control coefficient right here coefficient okay again the P stands for positive this makes sense right now positive temperature this stands for again coefficient coefficient let me just get that okay so what does this mean so when it comes to ntcs right one thing to keep in mind is when it comes to ntcs is that okay when it comes to and ptcs is what they're both affected by temperature okay but the difference here is that when it comes the ptcs what happens is resistance value it increases by what by increasing temperature okay so the resistance value increases by what by the amount of the temperature right here when it comes to PTC to the NS what it is what it's opposite so the resistance value What in increases per decreasing temperature so as soon as temperature starts to decrease the resistance value what starts to what increase again this is what due to the material they're made from they're made from different materials so again in this case the resistance goes up while temperature goes up in this case the distance goes up while temperature goes down again we can put this again we can put the inverse of this so the resistance goes what down when the temperature goes up we can say for this one too the resistance what goes down when the temperature what when the temperature goes down okay so in this case what the resistance and temperature have what somewhat of a what they're directly proportional basically they have what a straightforward relationship while in enes what do they do they have an opposite they have an opposite what they have an opposite an opposite relationship there's we can say R is what indirectly proportional to what to 1 / T we can say R is directly proportional to T for what her positive what temperature coefficient so so it depends on what it depends on the on the therm we have here it can be NTC or it can be PTC okay so while keeping that in mind right one thing I wanted to do here was you know what I want to check if the temperature goes high or low but the problem being here is I have to use something that has big source of heat and I don't want to get this what close to my Arduino because it can what it can ruin my Arduino I don't want that to happen that's why I'm just going to be using the light so I'm going to be using light I'm going to be using a normal lamp here and this lamp heats up especially in the back it's heat up right now that's a lot holds a lot of feet here there's a lot of feet here there's a lot of feet here and I want to do is just get it close here so we can see if the uh if this one changes or not if the LED changes or not okay let me just turn off my light this light I'm going to need one light only let me just remove this for now because we don't need it and now I'm just try to turn again with the light on what I want to do is again get this so close to the what the ther so that maybe we can see a difference the what and the LED do you see a difference I can't let me just do that keep trying to but I don't see any difference barely even see any difference there might be a difference but it's going to be very little that we cannot see it in our eyes both of us um so one thing I want you to keep in mind right now is okay I want do to keep in mind let me turn on my lights right now for now just turn this on right here and this one on one thing I want you to keep in mind is this thermister does not change very easily why is that so this one specifically again check your label specifically this one has 10,000 amps so what has 10,000 amps the resistance is Big so it's going to change for what for bigger temperature Okay so I just want you to keep this in mind again one thing I want you to keep in mind is not about the I want you to keep in mind is all right right here this has 10,000 Ohm resistor just like how the potential meter has a total combined of 10,000 ohms again it has 10,000 ohms 10,000 ohms of resistance this one has a 10,000 ohm of resistance too again I check the what I checked the label the label has it written out because it just says 10,000 oh next to it okay on the label okay on the paper that I had my what my Arduino kit just basically say it here 10,000 on it's going to go to components right here and all I need to do is go to the components and be like oh there we go they have a ther right here it has what 10,000 ohm I have two pieces of what 10,000 ohm therms okay so this is what 10,000 ohms which is a very very big number so what so we cannot change the we have to change the temperature very very by very big numbers I'm talking by very big numbers for us to see a change in what in their resistance because again why because I said again either they're very they're related directly or they're related to what indirectly okay so one thing to always keep in mind is what what one thing to always keep in mind is what the resistance is either directly related or indirectly related to temperature so right here 10,000 ohms is a very very big number so we're get going to have to change it by very very big number by very very big temperature for us to see a difference in what in the resistance basically we're going to have more current so we can see the light here so we can see the LED here just keep that in mind that's why I'm going to need to maybe use uh uh if I can match and sticks or something that is so hot so that again this can change in value but I just don't suggest that you guys do that if you want to do it I highly suggest that you guys use uh a digital again those digital arduinos or simulators again because you don't want to get hot stuff near to your again electricity this is not what recommended specifically especially for kids so uh don't do that as far as you can don't do that all right but one thing you need to keep in mind is what thermost always change in what they always change according to what temperature just keep that in mind all right this was a bit of a long one so um see you in the next section actually so um see you then all right so now let's discuss about U temperature s sensors so so far we've not discussed about any sort of sensors in this AR course so this is going to be our first sensor that we're actually going to talk about so let me just bring this closer so you can again see it so this is a temperature sensor specifically called the lm35 and um you might have a different type of sensor depending on again your Arduino kit the Arduino kit that you have but uh first uh we're going to see how you're going to know what type of sensor you have so obviously the first and the best method to know what type of sensor you have is always again reading the manual okay so I'm just going to bring my manual right here my man manual that I got my quit K Form K from and what I'm going to do is search for the components right here and when you read right here it says one one piece of what lm35 temperature sensor okay so again depending on the kit you have you might have a different type of uh temperature sensor but uh most of them uh we're going to check uh two sensors so we're going to see we're going to check most of them okay so even them two I'm going to show you guys how to actually see what typee of sensor you have and adjust accordingly to the sensor you have okay so first things first what I'm going to do is try to explain what these sensors are okay so let me go right here the LM right now specifically what I have is what the LM sensors the lm35 okay the lm35 temperature sensors but there's also one other common sensor which is called the dth there's like a dth series the dth 11 for example there's something called the dt22 and these are one of the most popular sensor right here so is this one but I think this is far more popular okay so we're going to check how the dted sensors and these LM sensors work okay so if you don't have those type of sensors I highly suggest that you guys watch a video of the sensor you have first know the sensor you have and then um check a video right the sensor name and then check the video of uh check a YouTube video on it okay that's what I suggest before starting this temperature sensor uh section okay so now what I'm going to do is bring the sensor okay let me work with the lm35 right now and the lm35 one thing you notice is what you order say three legs okay so you're going to put it where the text is there's a just Buu right here you can see a DOT a black dot right here not only that too but it's rounded but we're going to go to the flat side okay the flat side of it where is there where there is a text we're going to connect it that way so the the most left leg is going to be connected to 5vt the middle leg is going to be connected to the analog read volt okay some analog volt again and the right the very right of this is going to be connected to the gnd D okay so let me just do that I'm just going to put it right here me just do that try to put it together let me just widen this a bit I need to make this a bit wider it's not going to fit in across I wanted to fit it across so let me just make the legs a b wider let me just bend them so that they fit okay there we go thinking how they fit better okay and come on on all right not the most even one but at least they fit okay so what I'm going to do is connect again the 5vt to the most left leg on the flat side again let me just do that the most left leg it's going to be connected to what it's going to be connected to the right here going to be connected to the 5 volt okay let do that right here connect the 5V and the middle one I'm going to be connecting it to what to one analog pen that I left my choice again let me just do that find an analog pen I'm going to be using analog pin maybe one today or maybe analog pin two actually let me ose analog pin two it's just far a bit closer I just don't want to stretch the wires okay and then afterwards what do I want to do I want to use use my gnd pen let me just do that let just go to my gnd right here connect that to my gnd the ground let me just check if everything's intact okay the g&d is right here yeah this is correct okay once I'm done doing that what I'm going to do is write down the code so let me go over to my screen right now and let's write a bit of code okay okay soly open my ardino ad right open one of this and let's set up our code so first things first we need to set up what our read pin okay read pin is what today today is analog two now we got two now what I'm going to do is set it up right here pin mode set it up as read pin and then is what as an input okay because we're going to be what reading from it okay reading that te's not right let me just get that and uh afterwards what do I need to do start the serial monitor because this is where we're going to see what we're going to see the temperature serial. Begin Again with what B rate 9,600 B rate there you go afterwards I'm just going to do a Serial print L I'm going to what I'm going to print a new line right here of what maybe the read value first things first I need to do what I need to read I need to analog read it so analog read all right so obviously this is not making sense I'm just what trying to read the value but what we're going to do is first is what change the red value to what to voltage first and then we're going to go to check the math and how to change it to Celsius all right so let me go to analog read in this case it's going to be what analog read the read pin this is going to be what it's going to be the read the red value it's going to be the value you're going to be reading said like this all right then afterwards what then afterwards we want to say calculat value calculative value is what the read value you got to divide it by what 1023 I'm actually we're going to multiply it by what just do a 5 point right here again you know why I put the point you can also put zero right here because it's going to be a float I don't want it to like round round up or down after it's done calculating it because then it's going to be a zero okay 5.0 or 1023 I can add a zero right here or not it's up to you okay then once I'm done with this what I'm going to need to do do is uh go right here okay there the Cal value calculator value okay so the change it degree celsius first what I'm going to need to do is go to my browser right here and I what what I'm going to need you to do is those people have an lm35 by the way are the only ones that are going to be following me in the section if you have uh D um DHD sensors I'm going to come back to them and actually show you in the next section okay so for those who only have lm35 we're going to proceed if you don't have a DHT or have another type of sensor again if you have another type of sensor again watch another YouTube video there are lots of YouTube videos again of any sensor that you really need you're going to find lots and lots of resources but if you're using a DHT hand gone wait the skip to the next section I'm going to show you how it's done okay so when it comes to the lf35 temperature sensor we're going to go to it Ste the sheet all right I want you to search us for what LM and the corresponding number right now I have 35 temperature sensor and go to data sheet all right let me just do that and you're going to find some sort of PDF around Precision Cent grade information and support just going to go here well actually the PDF is right here say 39 Pages here so let me go here to the PDF all right and there's on this PDF right now the documentation of the lm35 you're going to see is what the description and the features it has it's can measure to what can measure look at it rated for f from 55° C to 150° CSUS this is what the temperature range all right the range of temperature is what from 55 to 150° CS so it can go a lot okay again this is going to be different for the type of LM that you have I have an lm35 okay so once you're done with that um reading this and by the way there are lots I'm talking 69 page of documentation but we're not going to get into any of these because they're Advanced all right and we don't need them in this case but again any information that you're going to need you can find it here in the documentation in the official documentation of what the temperature sensor okay so one thing that you should focus here is right here you should focus at this one I have it highlighted there we go this one it says linear plus 10 Mt per degree Celsius scale factor so what does it mean it's saying that the scale factor basically is what it's going to what it's going to Output 10 m per every degree celsius all right so for every degree celsius that um it monitors again it's going to what sense it's going to Output what for for analog pin in the middle the blue pin the blue wire it's going to be outputting what 10 molts okay so it's going to be outputting 10 molts Okay so right here let me just bring my paper right here paper and let me bring the Sharpie and let's try to understand what that means let me just put this out of here for now okay so let me just draw a line right here and let's focus on this line on this bace okay so what does this basically mean h 10 molt per degree celsi let me just write this down it means 10 molt per de Celsius is what the scale factor okay I want you to focus at this what do we want to gate we want to Output what we want to print the what the temperature we want to put print the temperature so what does this mean 10 m volt means what Millie stands for 10 the^ of minus 3 so it means 10 * 10^ ofus 3 volt per degre celsus is the scale factor which means if you multiply this this becomes 0.01 volt per degree Celsius is what the scale factor all right so what a scale factor right here let me just bring another paper okay let me just do that I'm running out of paper right here just bring another one so what does the 0.01 volt per degree Celsius mean okay you said this is what the scale factor again scale factor is what voltage over temperature you can see their units what is the unit of volt voltage so what does this mean volt over what's the unit of degrees Celsius what is the what do we what is U sorry degree Celsius is the unit of what it's the unit of temperature okay and this means V overt is what the scale factor it means voltage over temperature trying to find what temperature again keep that in mind okay so temperature is basically what the scale factor so let's do a crisscross temperature times the scale factor in this case it's going to be what the voltage all right so we're going to divide both sides by the scale factor okay then temperature is going to be V over SF again what is SF SF is what 0.01 volt per degree celius the value is what without the unit again if we just do the unit it's 0.01 okay that's one thing I want you to keep in mind these two temperature is what volt over scale factor and scale factor is what the value of scale factor is what 0.01 volt per degre celius why do we need to change from Mill volt to volt because as I said again let me go over again to my screen because our calc value is going to Output in what our calc value is going to Output in volt not in molt that's why I have to change the standard from Mill volt to volt all right because our Cal value our calc value was going to put in what in voltage in V okay so what are we going to do right here so we're going to need to set up what we're going to need to set up uh the what the scale factor so what I'm going to say is here um int scale factor actually not int it's a float float I'm just going to say scale I make this very short scale F it's going to be what it's going to be set to 0.01 all right and then I'm going to need what temperature I'm going to say temperature I'm not going to set it up yet then we already have calc value I do not set up calc value and read value right here as you can see in my code I have to set it up right here I didn't do that so that's always what recommended to set variables first and then what and then assign them you can do the opposite way again some sometimes you might forget about what you might forget about setting it up so I already set up uh float and temp so let me just go right here and set up read value so I'm going to say float read value do I really say float or INT in this case read value is going to give me what a number between 0 and 1023 it's not going to give me what a float number so obviously in this case I can say float or I can say int it doesn't really matter but I can say int right here it's again makes sense for me to say int okay so you can say int or float but I'm going to again say float because I'm going to be multiplying this and working with this so it's suggested that you say float because you don't have to think about it when you say float you have to think about let's say in this case read value outputs 1023 okay if it's an integer it's going to Output it as 1023 okay if it's a float it's going to Output it as what it's going to Output it as 10.3.0 which is exactly the same thing that is a float it's going to Output it like that which is exactly the same thing so when you say float you don't have to think about the most things you don't have to think about them okay so you can just say float and just not think about you know it um it uh about it being integer or not you can just use float for almost everything okay so after using that what I'm going to need to do is after I'm done with my read value okay I'm going to need float calc value now I need the float value because I'm going to be multiplying and dividing all right float calc value let me just set that up okay once I'm done setting that up temperature is what as we said again temperature is what temperature is what temperature let me just go again Point here voltage over what scale factor so our voltage is what the value that we're going to be receiving right here over the scale factor it's going to be salecore F okay so let's print the temperature right here let's print the temperature let's just do that let me just first check if our quote is right it's saying that I'm not put a semicolon I have to put a sem calling after every one after every line code let just do that and okay it's done compiling and first thing I need to do is what connect my Arduino I did not do that okay let me just do that let me just bring that right here and connect my Arduino just forgot to do that okay now I can upload hopefully let me just check if it's connected should be showing me my port okay just select the port and let's upload it it's uploading and it's done uploading okay we're receiving numbers very very fast so one thing I'm going to do right here is give it a delay forgot to give it a delay because it's going very very fast I can't even read it let me go delay and let's set it for 100 milliseconds 100 milliseconds we do actually you know what let's do 250 because it's going to be really fast I don't want it to just go really really fast I'm just open my ceing right here it's going to open it itself okay let it clear out let me just clear this out let just say clear output and then it should be giving me an output just 28 so it's saying that I have what 28.35 degrees cus by the way for those of you are thinking you know what why are we getting 28.3 how am I supposed to change this to Fahrenheit or everything why did I why why is it specifically degre Cel why is that so again let me go the documentation it says what from 55° C to 150° C and the most important part what it's saying 10 molt per degrees C right it's saying 10 molt per degre celsus what scale factor so basically what we're using the what the unit Celsius that's why I'm exactly sure that it's using what degrees Celsius all right so if you want to change it to degree F all you need to do by the way let this be homework for you so what I want you to do is pause this uh this course right now pause it right now and all I wanted you to do is change the degrees Celsius to Fahrenheit we already gave you the degree celsius right here which is going to be uh it's going to be temp TMP temp I want you to do what I want I want you to convert it to Fahrenheit okay so pause the video and do it right now and I'm just going to do it right now so pause the video all right so I think you youve done it because I think it's simple but if you have not done it what you need to do is first pain the formula what is the formula of what temperature Celsius to fahren Fahrenheit formula just find that formula right here all right there we go temperature degreed Fahrenheit is what temperature in degrees celsius time 9 over5 let me just go over and first what assign a variable for Fahrenheit all right let me just do that let's go right here and let's say you know what float float what float temperature and let me just put capital F just to say it's Fahrenheit okay so let me go right here say temp f is basically what what did it just say let me just go back to my Chrome and try to read the formula right here it's what temperature and degre Celsius time 99 over 5 okay that's simple temperature and degre cus given by H right here then we're going to multiply by what by nine again we need to put what because we're dividing what do we need to do we always need to use a Point 9.0 or again 9 point again it's up to you 9 point and put a dot at the very end dot there we go what else do we need to do let me just check that out and then we're going to add it up by what by 32 okay we need to add it up by 3 32 okay I'm then to add it up by 32 so one thing that is confusing a bit for me is uh am I supposed to multiply both of them by 32 I'm sorry am I am I supposed to multiply the whole thing by 9 over5 or am I supposed to just multiply temperature by 9 over5 and then add 32 um so to just check that let me just go right here actually should be giving to giving it to me on uh actually wait let me just go to something that was written by hand so let me go to images all right there we go now I can clearly see the temperature has to be multiplied by 9 over5 not the whole thing you see that it's not the whole thing that's going to be multiplied by what by 9 over5 only the Celsius will be multiplied by what by 9 over five all right I just wanted to get that on my mind right there off my mind so what I wanted to do right here is seral and get printed new line temperature F okay seems good now let's try to upload it oh I forgot to do what put a semic calling at the very end I should have done that right let's just upload it right now should be working it's done compiling and I think it should be uploading all right there we go let's go back to our ceing monitor right here let me just extend it we're receiving lots of values but obviously it's getting a bit confusing here we do not know which one is the degree celsius and we we do not know which one is what which one is the degree Fahrenheit so what we're going to do right here is you know what for degrees Celsius let me find degrees Celsius right here this is temp degre Celsius what I want to do is before this what I want to do is basically serial. print okay next to it a string Celsius literally Celsius basically what Celsius let me just say c cus c as an indicating celsus and I'm going to need space okay let's say c for Cal and I need to do is what serial. print for what for Fahrenheit one thing that is important here to notice is what it's not print Ln it's print so basically what happens when you print by the way what happens when you print something in the serial monitor what happens let me just go over to here my screen let's say I'm printing 25 all right 25 is specially the degrees Celsius let's not forget focus on the on the value of the serial monitor Focus here on the writing okay so 25 let's just say that what's going to happen here what basically going to happen is what first C is going to be printed out okay C and then what it's going to be print what what is going to be printed next to it temperature it's going to be printed next to it basically let's say it's 25 right here it's going to be printed next to it that's what I expect again so I'm going to expect this and I'm what what do I expect text so let's see actually if my code is even correct because I've never used this before so let's see if even if it's correct I keep forgetting those semicolons at the very end it's my bad I'm just brushing it a bit well because I have to go back to the DHT sensors all right come for there we go you see that we receiving C is 27 fahan is 83 they receiving that a very very fast speed you guys can see it fluctuates a bit but much of the last is the same so let's say right now I'm just going to read one of it let me just take off this toggle okay the automatic toggle let me try to read this one it's saying what 2737 de C which is basically what 8127 degree what Fahrenheit so again I have another homework for you and this is again predictable but I have a simple homework for you which is going to be that I want you to convert it to what to degree Kelvin and I want you to Output what Fahrenheit Celsius Kelvin I want you to Output Fahrenheit Celsius Kelvin so pause the video and do that okay so I suppose that you did it yourself but if you've not and you want to be you know you want to make sure that you did it right let me just go right here what basically uh temperature Fahrenheit is is basically temp K let just write that down what basically temperature at Kelvin is just adding 273 at temperature Celsius that's all you need to so let me just Define it right here temp K is going to be what it's literally adding 270 it's going to be like 10th plus 270 that's all you need to do all right that's all you need to do so all you need to do right here is again we want to print it so we're going to say serial do print not Ln only print and we're going to say k again put it a column right here finish it with the semicolon let's say serial. println new line and then we're going to print what temp K capital K let me just finish this with a semicolon right there okay and let's upload it okay it's saying there's an upload eror I don't know why let me just check it again can't open device let me just try to run it again let me just compile it okay the compiling there's no problem in compiling so let me try to upload it so there's most likely a problem uploading hopefully it's not going to happen again okay still uploading all right all right there we go let me just clear this up and it should be running there we go we can see C is what F and then a k we see a c and an f and a k a c and an f and a k a c and an f and a k that looks beautiful let me just go to the bottom again I just wanted to toggle to the bottom and if itself but you can see it we have what c f and K coming simultaneously all right that's all you need to do when it comes toward Works temperature sensor I wish that I could bring something colder and hoer right here so we can see the temperature move around but mostly when it comes to temperature it doesn't change a lot okay and again I don't want to bring something that's very hot or very cold near my already we know that's why but again you can check it for yourself using a digital simulator try to use a digital simulator and again try to toggle around mess around with these temperature sensors it's up to you okay you can do that or use again be careful when you're doing whatever you're doing so if you're using something hot or cold be careful when you're putting it close to the um to the to the sensor okay be close especially with the wires okay because they can really just block your view right here here so you need to be close again you need to be what you need to be cautious of what you're doing so if you're even thinking thinking of bringing something cold or hold to just again check the temperature sensor be careful about it okay so um that's about it for the lm35 sensor and for those of you who have again DHD we're actually going to see the DHD sensor so uh you guys uh I might as well uh skip the DHT sensor because I don't think you're going to be using it if you have an lm35 okay so for those of you again who wish who watch this uh section are going to be using LM the LM series The lm35 the LM 36 and all these series okay the ones that use the LM obviously what I want you to do is what I want you to skip the next section because I'm going to be talking about DHD sensors okay so keep that in mind so um see you in the very next section okay so now let's talk about the DSD sensors okay so one thing I want you guys to keep in mind when it comes to these temperature sensors is there's a lot of them there's the TT there's the lm35 there are even different types of again sensors that are again unknown okay so one thing I want you guys to think about is what I want you to think of them as Samsung and iPhone so when you look at them both of them are phones there have a lot in common but they also have their differences so obviously they look different again they have different features but they do what basically the same thing so they what they make us you know we can use it to what to call for example we can take photos with it we can use apps with it okay so one thing I want you guys to keep in mind when it comes to temperature sensors is there's a lot of them with different numbers but they have what but they are mostly the same all right so they have again difference in features and again difference and again how they look and all and how they're hooked up again and how they work but they're what they're essentially nevertheless they're what they're the same more or less the same okay so let's bre about the DFD sensor so you're going to be searching up again your sensors again the equivalent sensor you have and check and check for the what for the connection okay right here I'm just going to demonstrate using a DHD sensor so I'm going to go to DHT sensor connection okay as what one of the most popular pits so right here as you can see let me just take let me just zoom out so you can see the whole thing zoom out there we go and as you can see right here is the most left side is connected to a digital pin right here so you can use any digital pins right here okay and then the middle side is connect to 5vt and then the very right side is connected the gnd D so one thing I want you guys to keep in mind is what this thing is going to be using digital read okay so it's going to be using a digital pins we're going to be using digital pins not analog pins for this one okay for reading I think most of you again we've been using so far what we've been using analog pins to read okay from the what from the sensors but in this case we're going to be using digital pins and I'm going to explain um in a bit while okay so right here again to make again our lives way easier we're going to be using a DHT sensor Library okay so you're going to be using a DHD sensor library that is by what by Ada of fruit okay so all we need to do right here to add it is go to Arduino go right here and go to our again let me go all right here and then search for DH sensor and try to install the one by eat a fruit there's a lot of DH sensor libraries so let me search for DHD and search for Eed fruit there we go DHD sensor Library by Eed fruit all I need to do is install it right here from the library manager and it says that there has a dependency right here okay so it needs what it needs this a fruit unified sensor library to be installed so if it does not if you don't install this the code is not going to work so let me install it all there we go it's both going to install the DHD sensor library and the E fruit there we go e fruit unified there we go unified sensor installed both of them okay so right here that's what we can do but another option is again to go to our DHD sensor Library you again Google It Again by eat of fruit and then you're going to find the first link all you need to do is Google it there we go the HD sensor library and search the Arduino link and then all you need to do is download the version again that you want so if you don't want the new version you can download the Legacy version anyways once you're done downloading that all you need to do is add it to go to Arduino and then go to sketches and uh go to include library and add it as zip as a zip Library okay so with that in mind we're going to be using eater fruit so once we're done doing that we say we go to sketches again and we go to include library and then we go to eater fruit again DHT sensor Library we're going to be using the DHT sensor Library so I'm going to touch that that's going to include the code for us so it's going to basically include it in if itself so we don't even have to write it down ourselves okay so again for those of you who want to read the documentation it's available on the ardino so again I highly recommend that you guys read the documentation after this video so I can use it for uh more things that actually is capable of so I'm just going to be explaining just basic stuff okay so with that in mind now what we need to do is actually use this set up this library and try to use it okay so right here you're going to be using Define hash Define and then type okay DHT what DHT right here DHT 11 so you're going to be writing down type and then writing down the DHT specific DHT model that you have so just like how we have Samsung s20 S21 when it comes to iPhone they have iPhone 11 iPhone 12 and all of that we're going to be writing down the specific model of the dhp the DHD pin we have right here okay so once I'm done doing that I'm going to be defining what pin we're going to be using for sensing it all right so right here let me look to my connection let me just search for the connection right here and it's digital pin two that we're using right here so let me write down digital pin two so it's going to be equals to what two basically and then we write down DHT HT and then we're going to basically what we're going to give it the sense pin okay sense pin and then it's going to give it giving it the type of pen that we're going to be using Okay so we're telling our DHD Library what we're telling it what type of pen we're using and then what we're telling it what the sense spin right here is going to be digital pin to that we're going to be using it and then the type of what the type of DHT sensor that we have okay so once we're done doing that one thing the DHD sensor is capable of is it can also sense humidity so we're going to actually use humidity too so we're going to be setting up humidity right here I'm going to be setting them as again float because they come out in decimals so when you hear again in degrees celsius we say 29.6 de celsus and everything so it's going to be again in float okay so set it up and float and then we're going to write down everything we're going to be writing them down with the three what with the temperature in Fahrenheit and Kelvin we're going to be writing them down in three forms all right okay so that's it humidity temperature Celsius Fahrenheit and Kelvin once we're done doing that we're going to need to set up our serial monitor because that's where we're going to be reading our again our degrees okay so we're going to be reading using our serial monitor so 9,600 as usual set it up and then we're going to begin so we're going to be telling what we're going to be telling our uh uh DHD sensor library to begin okay then once we're done doing that we're go to our Loop code right here okay and then we're going to set up again the the values that we just want that we set right here so we're going to be again uh assigning them the ones that we just set here so let me go to humidity and set it to we're going to say HD that we already began right here okay that we began right here we're going to be say hd. read humidity okay read humidity and we're going to go for temperature Celsius and we're going to say HT what read temperature okay read temperature you can predict this since it's read humidity and now it's obviously going to be read temperature okay that's what we're going to be basically doing when it comes to the temperature Fahrenheit and kin what do we do we convert temperature Celsius to what to Fahrenheit how do we do that obviously we use the formula so let me search for a formula right here Celsius to Fahrenheit formula there we go Celsius to Fahrenheit formula is what uh Fahrenheit is what degre Celsius * 9 over 5 + 32 okay so I go to my code right here and then what I go to temperature Fahrenheit and say oh I want to do is what I want to use temperature Celsius I want to multiply by 9 over 5 plus added with what 32 so right here I did what I did two mistakes right here so you guys can actually see it what is the first mistake right here the first mistake is what we're not using decimals when we're defining what do we want to do we want to use floats so we need to put what a point or a point L okay that's what we need to do we did not do that that's the first mistake that I did right here obviously if I said 9 over 5 it's going to be what I actually did 9 over five right here what is the value 9 over five it's 1.8 and it's going to round it to what to an integer right here it's going to be rounding it to what to an integer so it's going to be rounding it to an integer I don't want it to do that I want to use it as a float so I want it to what I want to I want to what set it to float 9 over five there we go what other problem do I have here the other problem that you might notice you might not notice right now is that what right here ardino does not know what are we supposed to what are we supposed to do this first this multiplication first or addition first it does not know what to do okay so we're running into another problem right here should it do the addition or the multiplication first if it does the multiplication first what happens temperature Celsius is going to be multiplied by 9 over5 and then finally it's going to be added by 32 but if we add if we do the addition first what are we saying we're saying oh 9 over 5 we're going to add it to what we're going to add it to 32 and then after adding it to 32 what do we do we multiply it to the temperature Celsius okay so right here there're going to be some confusion what do we want to do right here let me just again look at our code let me just look at our formula right here it's better that way where's our formula let me just go back there we go can you see it we wanted what we want to multiply it first and then add it up okay we want to multiply it first right here you can even see it right here we want to multiply it first and then we want to add it up how do we tell our we know to do that obviously we need to do is what we need to put a parenthesis okay so let me just put a parenthesis right here the parenthesis there we go put a parenthesis all of this so I want uino to do what I wanted to do it together I wanted to divide it first and then I wanted to what I wanted to add 32 as a whole okay then how do we go to temperature Kelvin when it comes to temperature Kelvin what do we need to do all we need to do is add 273 from temperature Celsius that's all we need to do when it to Kelvin it's very very easy okay once we're done doing that actually it's better to use what again it's better to use float numbers again we're using a float number here so it's technically best to use float numbers here too okay instead of using integers okay then what do we need to do that's all we need to do that's all we need to do so we found the temperature Celsius Fahrenheit and Kelvin we extracted those information already okay so right here what we need to do is what all we need to do is print it out how do we print it out we see temperature Celsius why are we writing temperature Celsius you might be asking me why are we writing it down well we're going to be receiving three values simultaneously so we do not know which one's which so it's going to act as our like it's going to act as if it's an indicator okay so temperature Celsius the string of temperature Celsius that's written down as temperature Celsius is going to what it's going to tell what it's going to be written next to what our what it's going to be written to next to uh temperature the temperature Celsius value right here so we're going to know which one's which okay so when we read uh the value right here we're going to have three values coming in at once so we're going to know which one's which okay so I wanted to print temperature Celsius so I put again U an end right here because they're written down I put a I put a a space right here why is that that I put a space right here I put a space right here because I I'm using what serial.print okay what happens when to use serial. print they're going to be written down in a what in a in a one line and it's going to be written down next to each other okay so temperature SE is going to be here and the value after the space is going to be what the value is going to be displayed but right here one thing I want to do is what I want to add it in a new line afterwards okay I want to add it in what in a new line after it's done doing that I want it to be in a new line and then I want it to print again Fahrenheit and then Kelvin so let me just do that print and then set temperature Kelvin that's all I need to do it's almost copying code right now temperature Kelvin actually wait let me do temperature Fahrenheit first because I set it up like that so be more fair to do it this way and then write down temperature Fahrenheit what do I need to do afterwards uh temperature Kelvin and and then print it a new line again temperature what the Kelvin temperature and then it's best to give it what a delay after reading it so you can again give it a delay and set up a delay time right here let me set up a delay time let's say U integer delay time let me set it up right here and set it to let's say uh for us to read it let's say 300 milliseconds so we can read it properly and put a delay of 300 milliseconds okay that's all we need to do so right here again all of this code again is pre-written for us and it's already what the library covers everything for us so all we need to do is not even understand how even the the DHD sensors work so let me go back to uh that's all we need to do actually let me just upload this let's see if it if it compiles properly expected what expected uh what what is this saying it's saying expected oh um parenthesis before these tokens oh yeah I'm not using anything here did I do anything wrong saying that I should use a maybe it's saying that I should use a semicolon at the end but I don't think that makes sense it's going to even give me an error right here and it just going through an error right now because I don't have my Arduino but for those of you again who have your Arduino and you hooked it up and all it's going to be perfectly working fine all right so just keep that in mind okay so one thing I want you guys to keep in mind is right now it's going to be working perfectly fine for you guys for those of you have a DHT sensor one thing I want you guys to keep in mind is when you're using DHT sensor says let me go to my connection right here and one thing the DHD sensor does is it sends out signals of zeros and ones really really fast I'm talking zero ones zero ones it's going to be sending out what bits of zeros and ones it's going to be basically saying zero means what zero means off and ones means on so it's going to be sending that very very fast it's going to be sending it in milliseconds okay so it's going to be sending um what a series of zeros and ones zeros and on zeros and on zeros and ones it's going to be sending that okay it's going to be sending it through the what through the again the the yellow wire right here which leads to what digital pin two so it's going to be sending what again it's going to be sending U zeros and ones zeros and ones and then our Arduino is going to be interpreting that all right it's going to be interpreting that it's going to be interpreting the zeros and ones okay so it's going to either output zero and one so it's going to be interpreting that and then it's going to what it's going to again write it down and print it to our what to our serial monitor okay obviously we cannot see uh we're using zeros and ones how do we um read zeros and ones in Arduino how do we do that we use analog week right because analog read lets us use any value from 0 to 1023 so when you're reading something we use what we use analog read okay but obviously we're using what we're using Library so again it's going to be the library is going to be the one that's going to be doing the analog read right here okay that's one thing I want you guys to keep in mind so why do we use that digital pins instead of analog pins so let me go right here and I think let's go with something more familiar with you guys so let me go all the way here and let me try to explain uh this right here here so when it comes to if you remember digital right what values did it give us what was the outcome of digital right it was either High which basically meant what it basically meant 5 Vol or on right when it came when the other option is what the other option was what the other option was write it down properly it was low what did it mean just the write low meant what it meant Zero Volt or basically what off basically meant off so there's like two outcomes to what to distal similarly as we have digital right and U we have digital right right here have digital right and then we have analog right we have analog right okay we do have both of them and we also have as we have analog read to we're familiar with analog read we also have something called digital read okay so what does digital read do digital re what it basically does is you can read the documentation for yourself but it's going to what it's going to give us what information right here so this what does is what it tells us if it's either what if it's either zero or one it's going to be telling us if it's either zero or one what does this mean it's going to it's going to be telling us if it's zero it means off or if it's on when it's one okay so it's going to be telling us that so it's going to be telling us if it's on or off on or off that's what basically digital read does when it comes to the analog read one thing that again why you shouldn't be using analog pin is we have 10 bits of information that is being transferred 10 bits is a what it's a bigger number it's more options again it's useful again but right here it's not because as I said again our again our we know our U there we go our DHD sensor always send zeros and ones bunch of zeros and ones really really fast okay so it's going to be either zero or one that's going to be sending but it's going to be sending it very very fast and then the Arduino is going to be interpreting that okay so the number of zeros and ones again inside of again the full information is going to be affecting uh again it's going to be tell telling us uh our temperature so right here it's going to be sending out 10 bits of information so what happens here is there's what it gives us value between 0 and 1023 gives us lots of options but what happens here the limitation right here is what basically what happens is what we only want zero and one we only want what zero and one because again as I said again our what our DHD sensors are only going to be using zero and one they're also they're always going to be outputting what zero or one on or off okay so they're not going to using this rest of the value right here from 1023 anything from what they're not going to be using anything from 2 to 1023 okay so it's going to be 10 bits of information always being sent out to what to the Arduino 10 bits of information being set out to the Arduino what is zero and 10 bits zero and 10 bits is what you have to write it down 10 times it's basically what 0 0 000000 0 0 write it down 10 times what is one in 10 bits one is what one one one one one one one one write down 10 times I have to write it down 10 times I don't think I down 10 times but the important thing is it's going to be written down in 10 bits okay so when it comes to the digital read right here we only need what we only receive zero or one so it's going to be sending it in one information when we have one bit what is the one bit of zero it's zero and if itself what is the one bit of one it's one what's the one bit of two it doesn't exist it can only count up to what it can only count between zero and one okay so that's one thing I want you guys to keep in mind so right here it's more efficient because it only sends out what it sends out little bits of information it sends out one bit compared to the what compare to the analog so right here the analog is going to be sending out 10 bits again and it's going to compound okay so it's going to be sending out 0 0 z0 again one one one so one thing I want you guys to think about when it comes to bits is like how we have conversations okay so 10 bits what can it do when it comes 10 bits 10 bits again allow us to what to access different amount of numbers lots of numbers numbers just like just think of me saying hey how are you and just think of it as being 10 bit okay hey how are you is what 10 bit and think of high it's what it's just think of it as one bit okay which one is faster to say high is faster to say why is that so we're transferring a smaller amount of information okay we're we're transferring what smaller amount of information right here so it's faster so the problem here is what the problem with analog readers it transfers 10 bit okay it transfers 10 bit and it's going to be what it's going to be slower when it when it's compared to the what to the digital read that's why it's preferred to what to use digital uh digital pins when it comes to this again dstd sensors I want you guys to keep that in mind yes you can use analog pins but it's going to be what less accurate and then also you risk what you also risk it being slower but when it comes to the digital pins we only transfer again one bit of information so it's going to be really really fast because the again RDH sensor is going to be sending out zero zos and ones and digital read is going to be very very fast again when it comes to what when it comes to the digital pins so just keep that in mind anyways with that in mind uh everything should be working perfectly fine for you guys for those of you who have it it's going to work perfectly fine and you can upload the code and you can work with it anyways with that in mind uh let's move on to the next section in this section we're going to discuss about switches so this is going to be a very quick and a very short section but it's going to be an important section because we're going to be discussing one of the most important parts and one of the most common components that we use in an Arduino not only in Arduino but in our lives okay so today we're going to be discussing about switches okay so switches they look something like this they have a button right here that you can push okay and we have four legs they come in different sizes this is a big switch the same type of switch and this is the same type of switch but it's obvious obvously smaller we need to do a side by-side comparison okay so one thing we need to understand about switches is they're fundamentally very very easy they're fundamentally speaking they're very very simple okay so before discussing about you know all these switches and stuff I'm going to get back to this we're doing that I think it's best if I discuss about current right here because it makes sense to do so because switches are used to do what switches are used to uh to turn on or turn off something so turn on and turn off a circuit all right so let me go right here and let's just again create a simple circuit okay do that this is what almost a complete circuit why is that so why is this a complete circuit because the positive terminal goes and it touches what the negative terminal it's a complete circuit How about if it was like this what happens if it was like this what happens if there is an opening between what the circuit right here between the circuit what's going to happen in this case obviously what's going to happen current is going to Flow by the way don't corre connect it direct don't connect your obviously positive towards the negative because we have no resistor here so going to FR Ado but again this is just for concept so current is going to flow all else is going to happen electrons will flow too if current is Flowing electrons are flowing again currents flow from what position to what position they flow from the positive to the negative what about electrons they flow from the negative to the positive they have what opposite directions they flow in opposite directions okay so obviously you know by now that electron flow is what generates current I just want you to understand that just keep that in mind okay but what happens here let's say electrons are again moving from the negative terminal electrons are moving they're moving they're moving they're moving here they're moving and they stop here because they cannot cross this boundary then what happens here electron cannot move the whole way so basically what's going to happen there will be no current flow so current will not flow because what happens because the electron cannot flow from what from the negative terminal to the positive terminal so basically no current flow because of why because electron can't flow because electron can flow in this circuit okay so this basically the same concept that we're going to be using in switches so switches when we turn them on they make it so that we can again flow electricity can flow can you see it electricity can flow but when we turn it off what do we expect we make it so that electrons cannot flow indirectly will not have what and will not have any current okay so right here let me just move this so let me just bring the switch right here and one thing you want to look in these switches is again let me just focus on the switch right now okay there we go one thing you want to focus on the switches is there are closed sites can you see this there are close sights here there are close sits here too and there are ones that are what they're connected to even par they're connected in this direction okay they're connected in this direction so one thing I always want you to keep in mind is the ones that are U the ones that are facing opposite the ones that are parallel to each other are always connected I want you to keep this in mind they're con they're always connected either when you either when you push it or don't they're always connected okay they're always what they're always connected okay when it comes towards um these these ones that are connected Ed by what they're on the same side so I want you to see the pins that are attached to what the same side when it comes to those pins what happens is there are what there are I'm just going to put this here there is a wire okay so there's a wire that's going to move it's a wire that is what that moves okay so right here when you push down okay when it comes to these buttons when you push down what happens is want you do again pay attention is when you push down what happens is these wi attach basically when they attach what happens current What flows okay basically when you don't touch it anymore by the way when you just leave it like this what's going to happen it's going to be open can you see this so electricity cannot flow from here to here but as soon as you push it down what's going to happen as soon as you push it down the wi is going to go down you're going to push the wire down right here basically what creating what creating a complete circuit this case current will flow okay so that's all you need to know to start with these but one thing I want you to keep in mind is this okay when you look at the smaller uh uh push buttons when you look at them spring them here when you look at them it's really hard to distinguish it's really hard to distinguish which side is which am I supposed to put it like this like in this way let me just actually Focus this way better let me actually put it like this it's better that way way all right there we go am I supposed to put this like this you know how am I supposed to know which one is connected like this which one have this type of connection and which one has this type of connection because it's really hard because they're symmetric when you look at them they're symmetric from both directions they're at the very edge and you don't know which one's which so always what you need to look for is what you need to look for a side that have two pins let me just let me Focus right here you always want to look for a side that has what a side that has two pins that are connected so we're going to look at one single side here and they're what they're connected to the what to the same what to the same side all right so these two pins are connected to what the same side so you want to look at these these ones are the ones that where the switching is going to occur I want you to keep that in mind these sides are what the ones where switching occurs when you look at these side when you compare this one with this one we just bring it open here wait it's not focusing my bad okay there we go when we bring this one and this one okay these ones they're parallel I want you to keep that in mind because why they're opposite they're not connected to the same side okay so the ones that are not connected to the same side what happens though the ones that are not connected to the same side the focus is really bad oh my this is really bad Focus all right what happens to the ones that have um that are connected to the opposite side okay I want you to look at the parallel sides so this side is right here there's a parallel side right here so the ones that are connected to parallel sides are connected in this way they're always connected okay either you push up or push down they're always connected okay so so when it comes to the ones that are attached to the same side what is what happens they're connected in the in the matter for is is connected in a condition if you push the button it's connected if you don't push the button it's not connected the ones that are facing the same side okay the same goes for this one to so I want you guys to again to use the side metaphor instead of uh using the ones that are far apart because in this one everything is when you look at the small one I'm sping the small switch when it comes to the small switch everything is what everything is equally distant okay it's a square side has a square shape so everything is going to be what equivalently distant so again look at the side so the ones that are connected to what the ones that are on the same side the same the pen that are on the same side have what they're going to be the ones where switching is going to occur the ones that are connected parall in the opposite side basically and parallel sides are going to be what are going to be the ones that are always connected either you push up or push down they're always connected I think it's going to make more sense when I just bring my Arenal right here okay so let me just bring this right here okay and let me just unplug my adreno for now let's just put this to the side so that you guys could actually reference it just put this to the very edge okay so let me bring my ardina right here how am I supposed to connect this I'm supposed to connect the ones that have the same side again the pins that are on the same side okay the pins that are on the same side how do I want to connect them I want to connect them across I don't want them to be together if that if they are together obviously what switching cannot occur so I want them to be in what opposite what in opposite obviously in opposite rows right here I want them to be in different rows okay so I'm just going to push it in as much as I can I'm going to put this across too because it makes more sense uh to put it across I'm just going to try to right there we go least a bit of a push all right there we go now it's uh now it's plugged in all right so right here let me just bring my my red pin and connect it to a 5vt what I'm going to do is build a simple LED circuit but in this time what's going to happen I'm going to be using a switch to turn the LED on and off okay so I'm again I'm going to put this on the first what on the first one on the first leg did that now I'm going to need a resistor where am I going to connect the resistor because I want switching to occur I'm going to connect it to the what to the second leg right here second legs right here we have to disconnected just do that oh righty okay there we go the second leg is connected to the resistor and then I have my obviously LED light let me just bring that just bring my LED light there we go LED light is connected right here to the what to the leg of resistor right here you can see it and then obviously I'm going to need my g& D my what my ground pin let me just get it right here and connect it to the gnd D let me just make sure that I'm connected to the gnd D I don't want to get it wrong there we go to the g&d okay so now what I have to do is what plug in my arino let me just do that all right seems to be working okay thir window knows on uh let me just check my resistor if it's okay okay let me just push on the button right now and let's see if it's going to turn on or off okay there we go it's turning on as you can see it it's turning on but as soon as I let go look at what happens I just I just touched it once let me just touch it once as soon as I let it go it turns off so one thing you need to understand here is these buttons that I have right now they're called where's my Sharpie right here there we go there's my Sharpie all right they're called push buttons push buttons okay push switches basically they're switches that what they're push buttons or switches how about the one that we use mostly we use is called a toggle toggle switch okay so right here when it comes to push buttons the name gives you a push button I just want you to think of it as a push door okay as soon as you like go of a push door what happen happens it goes back to what to its original position okay as soon as you let go all right when it comes towards uh the doors we have at home and stuff if you don't again put excess amount of force what happens is if you just put it in the middle it's going to stay in the middle if you just leave it there if you just again push it and then you leave it at a position it's going to stay there it's not going to move in of itself it's not going to what close by itself just like how again push uh push doors do okay so I want you to keep that in mind when it comes to push buttons you always have to push okay for it to what for it to right here let me bring my paper for it to always what for it to always connect you always have to push to what for it to always put down this wire right here okay this connecting wire right here so that what it switches switches on okay so you always have to push when it comes to toggle switches the ones that we have at home what you have to do is what you only touch it once and you turn it on that's it that's all you need to do but again touch it again and what it's going to turn off those are what toggle switches so right here we're going to be using what push switches or push buttons here okay so we have push buttons so as long as soon as you let go of again as soon as you let go of the switch or the button what happens it turns off okay there we go so let me just bring this here and let me try to connect it to the one that is parallel right here let me just try to do that so let me bring my resistor right here just pull it out you've seen that it works the switching works when we're using what when we're using the pins that are on the what the legs that are on the same side let me just try to connecting try to connect the ones that are parallel okay let me just do that again let me just unplug my ardino because again it's better to what to always unplug your ardino work on your again physical project and then plug it back in okay let me just do do that let me connect my led to the leg of the resistor okay and I need to connect my what my gnd okay everything seems to be good and everything should be running by now let me plug it okay my resistant is is the one that is causing the problem let me just go here push it okay this leg is not pushed let me just push it to push it really hard oh okay I have to push it really hard okay wait let me just get my resistor let me let me fix my resistor right here think the resistor that's causing the problem I think it is as soon as I push it back in it's going to work you just go over here push my resistor Jesus keeps bending the leg keeps bending wait I need to straighten this out first let me straight it out all right connect it right here come on is the resistor connected properly uh yeah I think it is but okay the resistor is a bit coiled I'm going have to fix this let me just get another resistor let we just do that okay there we go makes our life way way easier okay I got another resistor right here let me just plug it back in plug it here plug the other one here and there we go I'm not touching it I'm not pushing it switching is not working here because why as I said again they're always what they're always connected they're always connected even either I push down right here it doesn't change the result see I'm pushing on the Buton right now I'm pushing on the switch but it doesn't change the result okay so one thing you always need to keep in mind is what the ones that are parallel again the ones that are facing parallel to each other are always connected regardless of them being pushed or not okay but when it comes to the again the ones that are on the same side what happens is again again we have to push to what to basically connect them so this is where the switching occurs all right let's just do this um using the smaller pen right here let me just do smaller one I have not used that but before doing that actually I have a really really a good question okay let me just unplug this right now what I want you to do is I'm going to put this all right as you can see I'm going to put this this at this third leg right now they're not parallel they're more of diagonal I'm just going to put this one connect it to this okay I'm going to keep connecting it to what to this one the one that is right here to the leg that is right here what do you suppose is going to happen let me just go right here what do you suppose is going to happen right here I mean I'm connecting this one to what to this connect the first one to this one they're more of diagonal all right let me I have to adjust my aduino again because I touched the resistor there we go the g&d is back here let's see what happens what do you think is going to happen though it's the real question okay so I'm just connecting my arino so let me just show you what happens right now you might be wondering why is this working as a switch we just said that you know the ones that are on the same side are the only ones that work as of what the where the switching occurs so you might be wondering what is going on well the simple answer is what as I said again these the first one and the second one let me just again bring my adino closer right here so that I can explain it let me point at it using maybe a pen okay these arinos are what these sides are connected as we said again the first let me just bring my just take out the wire for now let me just push it right here the first two are always connected as I said again the first two are always what they're always connected as I said again they're always what they're always connected all right so they're always connected so this side is always connected to this side so this side and this side is going to be what directly connected and what did I say this side and this side basically this side and this side this side and this side basically this and this the ones that are that are on the same side are what they're connected if you what if you push down again this is where the switching occurs so they're connected when you push down so what happens here this is always directly connected and then when you push down this also becomes connected so you see it moves the electricity moves from here to here which is always connected just again pull the wires right here it's always connected from here to here and then what happens and then when you switch down this and this is connected so indirectly what happens this and the resistor the 5V the red wire again this and this become what indirectly connected so again I just want you to keep that in mind all right so one final thing is before moving on um on this section is this is a bit confusing for people again as I said I don't want them to be confused so let me just unplug everything switch is really hard to get off right there we go took me a while okay it's a bit confusing for people and had even had to do a lot of research before even making this course because it's a bit confusing okay so one thing again as I said is what we're going to always look for sides okay so the same side we're going to be looking wait let me just focus here the same side we're going to be looking for the same side so they're always what they're always connected to what they're always connected let me just focus again they're always connected to what in the condition that we push this is where the switching occurs again so I have to connect them in what I have to put them in a way where the same sides are what they're in opposite what they're opposite rows they're in what in different rows okay let me just do that let just put this in the middle around here connect that push it again you have to push by the way these buttons they take a lot of effort and you have to push them just make sure that you don't break them okay there we go just do it gently okay now I can do is what connect my arino what is the all right let me just go here actually connect the 5V right here right now what do I need to do my resistor let me bring my handy resistor here and I need to do is put it what across again I'm going to put it right here across and what do I need to check that you know obviously the current is moving or not LEDs we're going to be using our handy LEDs and then we're going to be obviously using the gnd D we're going to be connecting to the what to the gnd D right here here so I need to do connect this to the what to the G and D okay so now switching should occur there we go as soon as we push again what happens as soon as we push it starts to turn on but as soon as we let go it turns off this is where again where what happens the switching occurs so the same goes for this one too it's EX the same thing all right the switches are exactly the same push button switches but the only difference is what their size and again their leg placement okay so if you always look for the sides again don't look for the ones that are far again far and uh closer don't use that reference because this one does not work here because this one is a square okay so there's nothing called far or uh close because they're equally distanced all right so you always have to look for what for the pins that are on the same side when they're on the same side this is where the switching occurs and when they're what where when they're on the parallel side what this is what they're always what they're always connected either even you push it up or don't push so just keep that in mind before uh moving on all right that's all when it comes to switches so um see you in the next section okay so in this section we're going to discuss about LEDs we worked with LEDs we've put lots of LEDs in our project but we're going to be discussing about a special type of LED so we've worked with u the the red LED the most but we also worked with what with the green LED and also the yellow LED we working on the traffic light project as you remember right here the important thing I want you guys to know is all right let's say we have a green LED right here I have a green LED right here all right that's good what if I want a pink LED what if I want a purple LED I have to specifically buy what an LED that is purple I have to specifically buy an LED that is pink if I want the pink LED that creates what a problem okay so how do I get any color that I want in an LED this is where RGB LEDs come to place okay they are called RGB LEDs and if you want to find them in your kit one thing you have to look for is that they have four legs okay they have four legs let me just focus here they have four legs not only that too but even the third leg right here the third leg is a bit longer okay I'm going to get to why it's longer but there's a third leg right here that is longer so we have to look for something that has four legs and looks like an LED it has to be clear okay doesn't have any color just like how these LEDs used to it's going to be clear okay so what are these RGB LEDs before getting into that I really want you to understand the science between color right so we have to understand we have to understand the basics of colors so that we understand how does this RGB LED work okay how does this r GB LED work okay so to do that let's discuss about something very very uh very very basic okay so I think most of us by now have learned that um the the three primary colors are what red yellow and blue if I'm correct we've learned that the three primary colors are what red yellow and blue all right right here though we're not going to be using red yellow and blue so basically obviously what does this mean these three primary colors they can combine to create any color that you want want any color that you think of yellow and blue together gives us green red and yellow together gives us uh it gives us orange red and blue gives us what red and blue gives us um purple and even you know even putting less red and putting more blue is going to give us more per bluish looking type of purple you know and it keeps going on so the list keeps going on so we can find any color that we want from black to white to purple to any color that you're thinking of can be made from what from the combination of what these three primary colors okay but we can also do it using another color instead of yellow instead of yellow we can also do the same thing by using green by using red green and blue we can literally create the same thing when we connect red and green what do you think happens when we connect red and green to be honest I really do not know when it comes to red and blue obviously what happens is it's uh it's again purple when it comes to green and BL uh it becomes sent I don't know what happens when you connect red and green I don't remember I really don't remember but anyways the main thing is it exactly does the exact same thing that we just mentioned here it can create any type of color can create any type of color that you're thinking of again with red green and blue they can be what primary colors so you might be wondering okay which one are we going to use when we're working with this LED and even with computer so let me just go over right here they are known this red yellow blue are known as subtractive subtractive colors why is that so so I want you go I'm just going to go over to my screen and try to explain it in a simple way okay so I think most of us know what a prism is okay so what does a prism do it basically what it basically converts the sunlight again right here that comes from the left side to what to a rainbow okay so what does it do it separates light it separates it into different wavelengths or different colors so that you can see each individual each individual what each individual uh color that makes what that makes the sunlight right here the sun okay so one thing I want you to understand here is that it's called subtractive for a reason what happens is what it is created by what by subtracting so what basically happens what it's created by what by subtracting wavelength of light so basically what it's basically created from what by splitting light okay by splitting light that's what happens when we're using a prison basically our day-to-day life when it comes to our day-to-day life obviously we gain light from what from the Sun so almost everything that we're going to be using is what it's going to be red yellow and blue made from these three all right because again it's going to be separated and then what happens and then when it's separated again we can see colors all right different types of colors okay then when it comes to the Computer World though there is a problem we use something called RGB even the name of this led right here it's known as RGB LED it's known as what RGB LED let me get to why we use RGB instead of R YB and what in our computers so the problem here is instead of separating light okay when it comes towards subtractive uh sorry subtractive colors they have to first gain light and they set separated so they gain light from the Sun what do they do they separate it okay they separate into different wavelengths or basically different colors of light okay when it comes to additive though why do we use additive in computers is we don't use the sunlight that's the problem our computers do not use sunlight where do they harvest energy they harvest energy from what from electricity basically when we charge our phone when we charge our computer when we charge obviously our devices so right here we're changing elect energy to what electrical energy into what into light energy this is very very important so we're not what we're not we're not going to be using a a light and then separating it we're not going to be gaining light from somewhere and then separating it obviously when it comes to our devices they don't what we don't use uh we don't use sunlight obviously to charge our devices that's why we don't use subtractive subtractive color obviously so right here we're going to be using additive colors additive colors is literally the opposite of what I said subtractive when I said subtractive what do you do we split so basically when it comes to RGB what do we do we combine you see that we combine these W legs of light to create any light we want so we're going to what we're going to combine them that's the very very important thing we're going to combine them and when we combine them what what happens we're going to be creating every color that we want again so we can find again R YB and RGB the fundamental difference between them is what is again this separating and this one what adding light okay this what blending light okay and it's very very again important what in computers we're going to be using RGB okay all right so with that in mind we have to first uh try to actually work with the LED first so let's try to understand this led right now and we're going to go and understand how the inner parts work okay so when you look at the Led it has four legs as I said again one leg is always what the third leg is always longer than the three legs so the fourth leg right here let me just bring it right here think let me just focus it all right let it Focus the fourth leg as we can see right here let me start from the first one the first the what the most left leg basically the first one is what it's going to be blue okay and the second one is going to be green the third one is going to be connected to the gnd D pen and the fourth one is going to be connected to what it's basically the R light okay that's what I want you to think of them okay so one thing you also need to keep in mind is okay this is going to be let's say a light compartment right here there's a blue light compartment and there's a green light compartment right here okay so basically what happens I said again when the red turns on for example the red is on and the blue is on what happens we get a purple okay because it's again an additive we have to add up together we add up lights okay when you add red and blue what happens we get purple right here so let's say it's it's just basically what turning on red LED and the blue LED what blue LED when you turn it them on it's purple so I want you to think of them as combining three LEDs combining red green blue LEDs into one LED okay just think of them as combining three LEDs into one LED and fitting them in this spce okay that's what I want you to think of them okay so it's going to be interesting is actually let me just put this again across it's going to be more interesting if we learn as we go it's better that way so you guys can actually retain the information okay let me just open this I need to pry it a bit open because it's not going to fit across if I don't do that all right that's better right I have to just keep track of it the third leg let me just again focus on this one I'm just going to keep it like this the third leg is going to be here here the G and D you need to make sure which leg you're putting okay this is the first one is what the blue the the most left one the second one is green the third one is gnd D and the fourth one is what the fourth one is R all right that's how I set it up right now so you might be wondering okay what is is all this RGB how am I supposed to you know find yellow because right now I've only talked about purple maybe creating a Canan right here but I've not talked about you know finding any color so let me go over to my screen right now let just do that and what I want you to Google is say color code or color pick say Color Picker and even Google has this so all you need to do is basically choose any color you want in this case let me just choose green for example let me just say the the most green thing let me just go to the most green one just choose that this is not the mo screen this looks the more screen almost we cannot see the difference right here okay okay this is the most screen one because it only has green right here the green one is the only one that's on this one is all off as you can see this is off and this is the red one is off anyway so you can just choose any Color Picker right here and find the value here and you can understand the value so you guys do not need to you know memorize anything so you might be wondering instead of why are we supposed to you know call them RGB why not just say you know we can just say you know if you want pink why not use the keyword pink if you want you know purple why not use the keyword purple you know doesn't that make more sense you know because it's going to be easier it's more easier and you would have to create a whole new system for naming what for naming lights you know doesn't that make more sense I mean it looks like it makes more sense right but the problem arises here the problem arises is we have different combinations of colors I'm talking Millions to Millions combination of colors that even provides Us in what when it comes to the amount of colors we can even see so for example let's say I want the shade of uh the shade of pink I just I just say I call it let's say I call it pink 55 okay I just called it pink 55 all right I just give it a name Pink 55 then let's say I move it a bit and I want it to be a bit darker okay I have to call this pink 56 let me just say okay let me just call this pink 56 all right let me go right here pink 57 uh Pink 58 you can see that when we keep naming it and naming it and naming it it's going to be what it's a lot you can see that right you can see that we cannot name millions of what Millions upon millions of color combinations because why it's going to be infinite the possibilities are what the possibilities are a lot so it's better to what to have a system and basically what direct ourselves it's like uh I just want you to think of just just using a simple analogy let me just create a paper right here okay let me just get a paper right here and let me just explain to you why RGB is important why having a system of what using naming colors is important let's just say you know what you have to hold 1 + 1 is what two okay you have to remember this all you do is remember this you're not going to go through the math or anything 1 plus one is what is true we have to catch this in our mind okay two 2+ 1 is what three uh okay 4 + uh five is what let let's just say nine um what 10 + 10 is what 20 all right just keeps going 50 plus 50 is what 100 okay and let me just say 1+ 3 is what 4 1 + 5 is what 6 1 + 7 is what eight so the problem is here what let's say I want to understand how to add up to a million let's just say I want to know how to even add up to 100 let's just say that all right I want to catch all the numbers up to 100 let's say 1+ 1 is you know two okay 2+ 1 is three I have to hold what almost 100 digits to even what to even count up to 100 okay but if I learn the basics of addition if I learn the basics of addition I can even add millions of numbers right here one 2 3 four five six seven I can just add this up just takes a bit of more time but I can just technically add it up I want to add it with 1 million right here instead of memorizing it what do I need to do all I need to do is add it up the answer is going to be 2,234 obviously 5 6 7 so basically what mathematics 2 is also what is a system as you can see right here instead of memorizing it what do we do we create a system so basically once we create a system it makes what we can count almost infinitely almost infinitely as in you know obviously we can't count to Infinity but we can do what we can do almost anything that's why instead of you know naming it just think of naming Millions upon millions of again color combination okay just think of naming over millions of millions of color combination we're going to do is what we're going to create a system of naming it and then what do we need to do all we need to do is go to our Color Picker and then what we can choose our specific color you see that right so we can just think of even thousands upon thousands shades of pink right here so right here let me just go right here okay what I'm going to do is move it right here it's right here moved all right let me just wait my my it's glitching out it's glitching out what happened to my computer oh Jesus I don't want it to glitch out all right come on let me just close this tab what is wrong with it okay my my computer is glitching out for some reason let me just turn off CH it just takes a lot upon lot of uh okay come on okay it's opening other stuff oh my God what's going on let me just ignore my computer for now and let me just go over to uh let me just go over to this again so that's why it's very very important to do what it's very very important to have a system of what naming colors because there's going to be Millions upon millions of combinations okay so with that in mind we're going to be using one of the most popular naming methods all right one of the most popular what color system methods okay the color methods and this one are RGB there is something else called heximal and I think uh some people might know it if you're familiar with coding and stuff but we're going to be using RGB today okay in case it makes sense because this is again as I said the LED is an RGB LED it makes sense for me to obviously talk about rgbs okay so now what I'm going to do is right here I want you to think of it is as I said again I want you to think of it as if we're connecting let me just go put the red right here the blue on the blue let me put the red on the red just put the blue right here and put the green right here and the red right here so remember us uh oh wait just let me just put it back here all right remember us doing obviously the traffic light LED what did we do it if you again I would really be I would really be appreciative if you just again go back and check it for yourself go back that section and check it but what we did is what we connected one resistor to the what to the red and then what connected to the what and then we finished and then we continue to what we continue to the green and then connected a a resistor for itself again a resistor for itself and then we connected another resistor for what for blue and then we did what we finally connected it to the gnd D that's what we basically did so one thing I want you guys to keep in mind is just because it's just one LED don't think that we have to what we have to use only one resistor all right I just I just told you guys I want you to think of what I want you to think of just us mashing up these three LEDs these three LEDs into one okay just think of mashing up these three LEDs into one and having a for leg right here for gnd D that's all I think what you guys redid All right so just think of mashing up again what this RGB LED just mashing it up together so we're going to need three resistors here I want you to keep that in mind again mashing up the red green and blue so right here don't use one resistor I think this is something that uh a common mistake that happens so please prevent that so again always what use three resist because we're going to be what lighting up red green and blue I just like as I as I said again just think of it as what as three mashed up resistors okay so as three matched up what LEDs okay so let me have to put this back again have to find the longer side again which is a bit of a hustle o it's actually a bit hard oh I found it all right there we go it's like this the longest side is obviously the ground pin where the ground pin goes so let's start working with our LED now is the right time I think to work with our LEDs I have to widen this a bit again I have to widen it so that it goes across to push it a bit there we go all right come on okay come on come on there we go got it okay so let me just go back to my PC hopefully okay for some reason it's glitching out okay so sorry uh my computer just crashed but uh let's continue where we left off so as I said again I just want you to think of the RGB LED as what as three LEDs separate LEDs what combined into one okay that's what I just said obviously it's going to be very similar to the one that we just did to the uh traffic light uh course but instead of using green sorry instead of using yellow we're going to use what green here okay so what did we do in the traffic light we separately did what again we separately what connected three digital pins three resistors and then connected it so what we're going to do right now is going to set up what three again digital pins for each color so we're going to be setting up one digital pin for red one digital pin for green and one digital pin for what for blue okay so let's just do that okay forget about the com the comment that I have here okay I'm just going to get back to this I just want to remind myself to uh teach about this along the way so we're going to get back to this but right now I want you to focus what we're going to be creating three digital pins so it's going to be red pin right here we going to start with red pin I'm just going to set it up to one digital pin I'm just going to say four today again you can choose whatever you want in then I'm going to choose the green pin what is it going to be again five eight any number you like I'm just going to choose five I'm just going to try to make it consecutive and then we're going to go to blueprint and set it to six all right then afterwards what do I need to do I need to go to pin mode then set it up to look I need to go to pin mode say red pin this case and set it as what output once I'm done with that obviously what I have to do is copy it so to do this in an easier way what I'm going to use is a shortcut alternate shift and then point downwards I'm going to be using alternate shift holding it it then I'm going to point downwards so I can copy it again see it I'm going to copy it three times then now what I have to do is what change the pen right here I just changed my language Let me just change it back to English there we go set it a green pen and then set this to a blue pin all right then afterwards what do I need to do as always I need to what I need to use digital right because I'm working with a what with a digital pin then I'm going to saying red pin and set it to what to a value of high all right again use alternate shift and again click down because again as as I said again it's going to make things easier than copy pasting them fting them from scratch so all I need to do right here is what change this to Green pin and then what do I need to change this to I need to change this to Blue pin all right so we're done uh setting up the code so let's start working with our components okay so let me just get this out of the way actually I should let it stay here to be honest because it's a bit of a harder concept so I want it to stay here so again you guys can reference this all you need to focus is not on the subtractive focus on the additive and again these three things all right just want you focus on these two things okay so what I'm going to do right here is I'm going to be using the red one for the red right here the red is at the fourth the green one the green I'm going to be using a green wire for what for green a blue wire for what for the blue color that's what I'm going to be doing green blue here green here and the red here that's what I'm going to do and I'm obviously going to use the gnd for the GN I'm going to use what a black wire okay so let's just do that so let me start with the blue one which is going to be the one at the very most left so let me just connect it let me get this closer and let me connect it now let it Focus now let me connect it there we go then what am I going to do right here I'm going to be connecting it to pin what again let me pin it's pin number six okay pin number six for me pin number six there we go then I am going to connect the green one let's just do that let's connect the green one with the what with the green wire so let's go to the green one right here it's going to be next to the blue one there we go let me just show you guys there there we go got it and then where are we going to put it just put this right here we're going to put it to the digital pin five okay so where's thisal pin five it's around here let me again make sure that you guys can actually see it Focus here digital pin five hopefully Focus there we go now you can see it there we go digital pin what connect the digital pin six and then digital pin five now the one that is left is what gnd D okay let me bring my black wire right here let's get my black wire and let me connect to gnd D there we go as you can see connected to the g& D and then now I'm going to connect it to the third to the third leg there we go Third Leg connected all right then now the fourth one I'm going to be connecting with what I'm going to be connecting it to the red so the red pin is what it is pin four so digital pin 4 let me go to digital pin 4 just did that just do that so let me just focus so you can actually see it I connect to digital pin for which leg the fourth leg there we go focus it right here the digital pin what digital pin 4 all right now I could just what I could just run so all I need to do is upload it let me connect my ardino let me just plug in my uino right here all right now I can just run it so let me upload it what I need to do is verify the code say snowboard selected oh let just select my board says unknown let me select it again sometimes this happens all I have to say is r no Nano there we go got my con 4 serial Port there we go and now we should be should be able to verify and it's done compiling now let's upload it okay so let me just turn off the lights so you can see way way better let me just do that because it looks like a greenish type of light right now let me just turn off the light right here both lights actually just turn this off too so you can actually see it it's too bright right now let me just try to focus it here it's a very very bright light you cannot you can barely see it it's trying to giveing me can you see green sometimes you can see red mostly you can see green but let me go over to this direction it's really hard to actually get a luck of this but it looks somewhat like what somewhat like white okay somewhat like what somewhat like white whsh type of color but when you put it here when you look at it on the screen it looks like green but genuinely what I'm getting is what I'm getting a white light right here by the way I can look at it white light somewhat looks like green on the screen right here can you see it we can see dynamic range of what colors right here I can see a red right now can you see a red right now can you see we have red green and blue when we combine them looks like somewhat like what somewhat like white so one thing I did not do right here is what by the way one thing I did not do right here is what use resistors I want you guys to keep it in mind I did not use a resistor well specifically speaking right here you don't have to use a resistor all right again specifically speaking you don't have to what use a resistor but it's not really stable when you look at it it just looks like it's changing color every time by the way it's not what is happening is what there's a red one the green and the blue are lighting up and when the camera focuses it Focus only on one color you get me right so when I change it right here it looks like a reddish when I change it a bit to another angle can you see it you can get a blue greenish thingy then when I change an angle again it renders it as other color but generally what I can see is what mostly what I can see is white but if you look close enough you can see red green and blue those red green and blue are turned on okay okay so let's just keep that in mind so if you go to my screen again right here and let's go to our Color Picker let's do that have to Google it again because I just said again my computer crashed Color Picker and if you go here through the very most white it is what it's 255 255 255 basically it's turned on to its maximum and maximum and maximum even if you go right here and say the RGB model just say the RGB model and you Google it if you look at it the intersection of the red green and blue the intersection of all of them is what it's white when we turn all of them what happens it turns to what it turns to White okay so inter the intersection of all is what it's one okay so let's just get this in mind okay so one thing again we've worked with let me again familiarize RV for you guys we actually did what we actually turned on all of this it's beautiful let me just bring a paper right here and let's go to the m math side of it as I said again there going to be what a math side towards it just like how we again use math to again systematically what add and all instead of what memorizing we're going to have this involves a bit of what this involves a bit of numbers okay so let me just remove this Pap right here and if you guys remember something you guys are getting familiar with let me start with something you guys are familiar with if you guys remember when we're using the analog I want you to focus here analog right command what did we do we sted the we stated the pen P right here what pin we we using and then we see a value from what from 0 to 255 if you remember wait let me get Pap right here from zero to what a number from zero to 255 an integer from 0 to 255 so one thing you need to know about RGB is literally what it basically means okay when it's written in this format is okay the first the first the first one represents present red the first value represents the amount of red and it's going to be from zero to what to 255 see that it's going to be the green one is also going to be zero to 255 the third value is going to be a blue which going to be 0 to 255 okay so if we have let's say a color for example that is written as RGB let's say 78 uh 241 and let's see this one is set to even zero right here the 78 is what the 78 is the value of what the value of red 24 is the value of what it's the value so 241 is the value of what it's the value of green okay I want you to keep that in mind and zero is the value of what the value of blue okay so the first value is going to be what the value of red the green is going to be what the second value and zero is going to be what sorry uh blue is going to be what the third value okay we just keep that in mind so let me go over to my screen right now and when we see something as 255 2255 255 what does this mean it basically means it's turned on to maximum it's turned on to maximum when we turn on everything to the maximum what does it give us the color white so again when we analyze the code let's just analyze the code right here we just did what additional bite High what does the just write high mean High means what high corresponds with what high corresponds with 255 as we learned again what does low correspond with zero corresponds to what to zero basically 255 means what 255 means 5 volt while low corresponds to zero which means Z volt Okay so we've just what created only white light right here what we've created is what white light but we can create Many Many Lights by using what by using the analog right command because why we can set it from a value to zero to 25 what we did is what set only zero to 255 that's all we could have done we only can set it to zero or 255 but now we can set it to any number between 0 and 255 so when we use analog right we're going to be what we're going to be unlocking new possibilities okay so what we're going to do right now is we're going to first change the p that we used again the digital pins we're going to be finding those squiggly lined pins again that look like what they're marked with a d and have a what a squiggly sign on them I told you guys that this pins are what both analog pins and they both function as analog pins and as digital pins so let's try to find those squiggly signed pins and try to use analog right command on them okay so let's just do that so let me just remove all of it except for the G and D the G and D always stays the same so I'm just going to keep it there I'm just going to keep the wires here because I'm going to get back to them again let me just take off this paper for now and what I'm going to do is go to my screen right here and we have to remove four or let's remove four five then six we're going to set them to what to the digital pins that have what squiggly sign so let's look at one that we have right here so let me unplug my Arduino right here because it makes no sense to plug it right now okay so let's try to find mine is an greo Nano so we're going to look for what for a DOT on the what on the digital pins so let's look closer and you can see one on digital pin 11 we can see one on digital pin 10 and we can see one on digital pin 9 so let's connect these three okay so digital pin 10 sorry there's still pin 11 10 and N are going to be the ones that I'm going to be using so let just do that actually I'm I'm not supposed to be plugging my arino I'm going plug it and let's start working with actually let's first assemble it and then we can go and write the code okay so digital pin 10 I'm going to be setting it to digital pin 11 is going to be set to Red I'm just going to do that I said again let me just bring this here so you guys can again remember it the red is what at the very very what at the very last so I'm going to be setting it to digital pin instead of digital pin 11 it's better to set it as digital pin n because it's going to be closer okay so I'm just going to set this to what digital pin N9 I'm going to change my mind and change change it uh and change it to what to digital pin 9 let me just set it to digal pin 9 right here set this to digital pin 9 where am I supposed to connect it next to the g& D pen to the very right so let me just do that there we go connected it nice now what do I need to do I need to set up green let me get my green wire right here let's find my green wire and uh put it right here I need to go to digital pin 10 I'm going to go for digital pin 10 for green okay then I'm going to go for the blue one which is going to be the most left one there we go and I'm going to set it up for what digital pin 11 oh SP is the space is very tight let me just do that there we go you guys can see it right now let me just do that let me just make sure that you guys can actually see everything every setup and there you have it okay so now what I'm going to do is let's go over to my screen and let's start writing the code okay so the red pen is what set set to what digital pin 9 while the green pen is set to digital pin 10 if I'm correct digital pin 10 there we go and blue pin is set to digital pin 11 there we go now what do I need to do right here I'm going to be using them as an output so this is all correct I'm not going to change anything here what else am I going to change here I'm going to be using what analog right instead of digital right so I'm just going to do that down analog right and I'm going to set the what the first one let me just set the red pin to what to some sort of value I'm not going to do that right now well I'm going to do set it up so let me again copy this set up green pin I'm going to set a value later and we have the blue pin there we go so now what I'm going to do is I'm going to go to My Color Picker right here okay so as you can see we have the value right here written down on RGB you can also see other values such as cmk HSV hsl we're not going to get into them because we're not going to need them right now but we're going to focus on RGB because this is going to be one of the most popular type of what color naming systems all right now a color what a color system all right so I just want to for something more of yellowish today I just feel like something yellowish let me just go for something yellow okay there we go I I like this color I want it to be a bit brighter though just make it a bit brighter actually but that that looks good I want it to be somewhat greenish though let me just go to The Greener Side of it okay that looks nice I like it so what I need to do right here is again the RGB says that I'm supposed to set it what 132 for red 20 55 for green and zero for what for blue so let me just do that let me go over to my ardino IDE supposed to be right here I have to set 132 for the red pen 132 for the green pen I'm going to set it to what 255 and for the blue pen I can just set it to zero okay so all I need to do is what upload this everything should be working no upload Port is provided why is that so I do not plug in my adino let me just do that forgot to plug my arino right here all right now let me try to upload it okay done uploading so let me just turn off the light so you guys can see it way better again turn off the lights it's really hard actually when there's when there's uh actually turn on the light actually it's way better with the light at least it's not going to be too bright that you cannot see it it gives me the yellowish you cannot see it again because of the screen again it's going to focus on only one light but if you look at it it looks like somewhat yellowish type of uh green it doesn't look like the one that looks on the screen like perfectly but it looks somewhat somewhat yellowish type of what type of green right here some yellowish type of green if I rotate it to another degree it looks like yellow you can see that right if I wrot it to a degree it looks like a yellow when I wrot it back to another degree it looks like green there we go there like a green right here okay so right here let me just try to make something of a distinct color let me just again and turn on the light let me try to make somewhat of a very distinct color that we don't have we already have a yellow pin so let's try to find something that we don't have maybe a cutor that we don't have maybe something like cyan because we don't have a cyan type of uh a cyan type of uh color right here can is one of my favorite colors I actually like it so much okay okay so the value of Canan is what almost what 238 255 but if you go to the closer side actually it's going to be 255 right here the most Canan color is going to be 255 there we go 255 this is cyan if you if you want to find for example by the way if you want to find a specific color okay if you want to find any specific color the RGB value of any specific color all you have to do is what all you have to do is Google it so right here you're going to goes right here and say um let's say I want the color pink okay so I'm going to say is pink what I'm going to say is pink RGB value or RGB code this RGB code or value when you just do that a pink is going to be right here the RGB code is what 255 192 and 203 all you need to do is go right here okay so I'm going to set the red to 255 let me just do that set it to 255 and this one to 192 well I need to do set it up to 192 if I'm correct let me just look over 192 192 and this one to 203 there we go all I need to do is what upload it right now let me just do that it's done compiling and now it's uploading it's done uploading as you can see right here let me just turn off the light if it helps you it looks somewhat like white right now let me just turn off the light so that it can help let me just do that okay so again it's was really a hustle you can see that the color is changing a lot it's changing from green to right now a red when I tilt it again and now to a blue but I at the right direction right here doesn't look doesn't look like pink right here looks like a pink right here can you see it a pinkish color I can see it right here it looks somewhat like pinkish by the way you cannot see it that much because again we're using camera but you can see what somewhat of a pink when I tilt it when I tilt it to the right degree you can see somewhat of a pink there we go somewhat of a pink right here there we go we got a pink that is beautiful let's just do that can you see it it's a beautiful one all right so um again you guys can choose any color you want Google it again any color you know maybe Indigo s any color you like Google it obviously and yeah all you have to do is search for the RGB value and you can again do what you can use your RGB LED and what and try to create that light for yourself all right I think this is it for the next section of for this section of the course but we're going to be working with RGB LEDs and adding up we're going to take them to the next level by uh working with the serial monitor on the next section of the project so um see you then okay so let's up this part project as I said again up a notch so everything here is going to be the same the components here are going to be the same so is going to be the code so we're going to continue what where we left off okay so right here what I want to do to up this project is use our serial monitor right here okay and what do I want to do this let me actually upload this code right here first because uh I was working on the pseudo code I was working on the code previously and I don't want to to interfere with this one okay I think the serial monitor should be printed now put my serial monitor should be like new all right there we go and what do I want to do right here is okay what do I want to do right here is I want to enter a message to what our serial monitor okay so as you can see right here there's a black bar that says message enter to send message to Arduino Nano so basically we can use our serial monitor not not only to read not to only what listen or read from uino Nano but we can use it to write messages to what to send messages to our Arduino Nano basically to our Arduino okay so how do we do that let's write down a message right here let's say I said red right here I can send it to what to the ardino obviously right now it makes no sense because obviously we have to what we have to create a system on which how we're going to receive the message and what Arduino should do when it receives the message okay we have to set that code up anyways we can set what messages though just like how we have uh I want you to think of this just like how we have digital just write it down properly digital write and digital read just like how we have that when we can write a message to again using our digital pin and we can read message using our digital pin too the same goes for analog too we had what analog right and analog read now we're going to have is what now we're going to have a Serial what we've been using what serial read we're reading what using our what a Serial Monitor and now we're going to be using what serial kind of something like what a Serial a Serial right type of thinking because we're going to be what we're going to be sending a message by using our what our serial monitor okay so what's the idea here the idea here is that we're going to set a color name right here let's say red and what I wanted to do is I wanted to change this led the RGB LED as I said again capable of almost any color to what to give me the equivalent color so when I say red I want it to turn to red when I say blue when I enter blue I want it to change to Blue when I say pink I wanted to change to pink when I say purple I wanted to change to purple again I wanted to change to what to the color I already what that I set right here on the message okay that's the idea of FL we going to be doing so the question is how do we even first receive the message from AR and how do we even code it so that what so that again it gives me the equivalent color on the rgbled okay so I'm just remove my serial monitor right now and we're going to be working a bit on the uh serial monitor so one thing we need to do before working with any type of Serial monitor is what we're going to have to always what start our serial monitor so we have to say serial. begin and set it to what to 9,600 right now and then we're going to be using right here serial. read string we're going to be using something called what serial. readstring okay so what I'm going to do right here we already started our serial monitor right here okay serial. what. read string let me just copy it okay serial. readstring there it is so what does this do let's just go to the documentation to check it for ourselves so what does the serial do read read string does for us so let me just go to serial. read string and there we go we have the arino documentation of it there we go so it says serial. read string reads characters from the serial buffer into a string the function terminates if it times out see time out so basically what does it do from a technical point they say what a Serial buffer into a straight so basically what does it do is what it reads the characters that are what are going to be outputed right here so it's going to be reading the characters that are going to be what that are going to be written on the message right here can you see this the message part right here this is the serial buffer and it's going to be what it's going to be what reading the messages that are coming from here so we're going to be using what serial. readstring to what to read messages that are coming from what that are coming from our message bar right here or our serial buffer okay so right here what we're going to do right here is we're going to need a new value a new variable we want to what once we get the value let's say right here I have red I put red right here let's say put red right here I want to what I want to store it because we're going to be using it in our code so what so I'm going to be using it later in our code so what I want to store it in a what in a variable okay so let me just do that so what do I need right here I need a variable so what is it going to be right here what type of variable is it going to be am I going to say integer and say you know what this is going to be the curent what set color let me just say set color right here the set color is it going to be integer is it going to be integer when I set it up no what is it going to be a string okay a string might correct even how to write it down I think it's string let me just again to always check that uh everything is correct right here let me just try to compile it saying that it expected a what oh it expected a semic colum let me just compile it okay the capital S is the right one if I put the small s well let's see what happens if I put the small s right here okay there we go it says an error I have to say capital S capital S is the right way of writing it okay there we go so you might be wondering what is a string uh let me just go over this so that it becomes what a simple as possible okay so a string is right here I'm not going to use my people actually I think it's better to use my screen so right here what does a string mean okay a string means a normal text okay for example this is a normal text right here it says put your setup code here to run whats okay but right here pin mode is what pin mode is a what let's let's go right here let's use an example of pin mode what is pin mode right here let me just go to pin mode what is pin mode pin mode is a what it's a command it's a what it's a code okay it's a code to be what executed so one thing it wants to identify is what it wants to differentiate between a normal text and a what and a what and a normal what and a normal code so wants to differentiate between what code and text which one is text and which one is code because if we don't do that we're going to get into what we're going to get into lots of troubles because if I just say right here instead of let's say I'm just say hello world it's going to expect let me just say hello world right here okay let me say hello world okay let me just try to compile this let me verify this look what happens hello was just not declared in the scope it's trying to find what it's trying to find a command a code named hello world okay trying to find what a code named hello world obviously there's nothing called hello world in the AR Rino obviously that makes no sense so what it basically means is what it does not understand that's a normal text or a Cod so to differentiate that we use what symbol we use right here what do you to call it a quotation mark you see that a quotation mark so we use quotation marks right here to what to identify a a one that is what code and a string so in strings we say double Mark right here and let's say hello right here hello world if I say that it's going to what render it as text it's going to treat it as a what as a normal text so it's not going to be giving me in so let's see what happens I just say you know what there's a strength name just say hello world okay always finish it with semicolon right here how about if I upload it right now let's see what happens it's done compiling see that it's done compiling it's not giving me an error it's saying is what this is just a normal text don't get into what don't get into detail just write what render it as a normal text okay don't do anything further than that it's not a command it's just basically what it's telling it so what it's a normal text so right here basically what are they called they're called strings okay so keep that in mind because why because I said again we're going to be working with what with what with letters right here and I wanted to render it as what it's not going to be rendering what it's not going to be searching for the what for the command or for the code red it's going to be searching for what it's going to be searching for what the string red it's going to make more sense as I go okay so right here I wanted to what to read the string how do we set this once it reachs the string I want to set it to what to a variable again because why I want to what I want to use it for what for later purposes so how do I do that what I do is I go right here sa color let say sa color let just go right here see set color set to what set color is equal to the string red value so once the value is red right here as soon as Arduino reads a value as soon as let's say I enter a value right here and it reads it it's going to set it to what it's going to set it to red right here okay it's going to set it to a value this the string that we just what that we just read right here okay so what does this mean so for example if I said red right here I just say red and enter it what is going to happen set color set color is going to be what go right here set color is going to be what set color is going to be equal to what it's going to be equal to the string red again what is one thing we have to uh uh sorry acknowledge what is it what is one thing that we have to acknowledge this is what a string there's what the quotation mark is right here okay keep that in mind okay so with that in mind now what we want to do is we know we said the color Okay so let's try to print what we just wrot right here so to actually see if it's working or not let's just print it okay we just say print Ln and say set color I just want to print it so that let's even see if it's what if it's rendering the right thing okay so let me just upload this but before doing what should I do turn off my serial monitor do that and now I can upload it's done compiling and it should be done uploading okay so let's go back to our serial monitor right here let me extend it a bit so you can see it better and let's try to say red right here does it print red there we go it printed what printed red can you see that it's printed red and you can see that it's printing out empty stuff can you see that it's putting out empty what is what is going on you might be wondering what is going on okay what is going on you might be wondering why are we printing out after red we're printing out something something what are we printing some empty spaces some empty stuffs why is that so let's see what happens again one thing again you have to keep in mind is what one thing you have to keep in mind is what it's going in a loop so it's going to read it one time and it's going to be you know setting the analog right to again all these values afterwards what does it do it reads the string in this case it was red I already wrote down red and then it's going to set the color as I said again it's going to what set the color so basically what sorry I said set color it's going to print it out it's going to print the what the variable set color and then what happens and then it runs it again but this time I have to write it what I did not write it this time so it's going to start from again it's going to start from again as I said it's going to start again because this goes in a loop again it's very void Loop so it's going to start again do the same thing but right here what happens here on the read string and this case what did I do I did not write down red again I have to write down red at very very fast speed for me to what to match up to what to match up to the Arduino right here what's going on the read string is what it's an empty set because I did nothing it's basically what it's basically empty because I do not enter anything so it's going to be giving me those empty spaces right here it's printing it out you can see that it's printing out what empty spaces okay so I just want you to keep that in mind okay so right here it's going to be printing out this we're going to fix this and by using something called serial. available I'm going to get to it but now let's focus on just optimizing the read string we're going to go back and fix this later okay so right here let me just get forget about the printing it works but obviously what happens again the problem here is what it's going to print out those empty characters we're going to fix that on the next one okay so one thing what we want to do afterwards after we store our set color is what our set color is what we want to compare it okay so how do we do that so right here let me write down an if condition there's the keyword called if okay we have a curly brackets right here our condition is written inside here okay right condition and then our code is going to be written inside of the curly brackets okay so when it comes towards um when it comes towards these if things if you write them down let me just write them down right here if I say if it has what a special color okay it's a code as I said again we're going to write down our condition what in those curly brackets and then we're going to have our code in the middle of those what in the on in the middle of this what curvy brackets again okay so this what the squiggly brackets right here okay so in the middle of the sorry the what in the middle of the uh curly brackets sorry I keep saying curly brackets for this one this is called a parenthesis okay in the middle of this is going to be the condition I I got that wrong when I said it but in the middle of the curly bracket is going to be our our code it's going to be written here okay so one thing I want you guys to keep in mind is let's use a very very simple analogy so you guys understand this so I think most of us have obviously uh had this English lesson about what if condition tenses condition tenses if you remember so when we learned about condition tenses what did we say what did we say there's a condition there's if and there's a condition and then there's what and there's what and there's the result of the condition so it's like cause and effect so one good example would be if okay if it doesn't rain if it doesn't rain going to say I will go outside uh to play basketball basketball let's start to analyze this so if it doesn't rain I will go outside to play basketball what is the condition here the condition is what it doesn't rain is what the condition this is what our condition okay this is our condition and the result of the condition again the consequence of the condition will be what what I will what go outside to play what basketball this is what this is going to be our action basically action so there are two things to this uh condition again there are going to be what two cases to this condition what is that what are the two cases in this case one case is what it doesn't rain so what I can just go outside and play basketball but there's another condition too when this condition is false basically when it's it's what it's raining when this condition is not satisfied it's raining outside basically right now what is going to happen I'm not going to go outside to play basketball I'm not going to go outside to play basketball because I don't want to get wet okay I just want you guys to keep that in mind so when this condition is what can be set to true or what it can be false okay both of them will have what when it's true it's going to have what when the when it's true it's going to have what I'm going to go and what play basketball and it's false in this case what it's rains what am I going to do I'm not going to go and play basketball so it's going to have what two scenarios when it's what when it's true or false when the condition is what true or false false so it's going to have what two again cases as I said again okay so it's going to what affect our what our action again it's going to affect our action this condition is going to affect our action the condition coming true is going to affect our action and the condition coming false is going to have what another effect in our action that's one thing I want you guys to keep it up so it's going to be the same thing too when it comes to computers okay so what there's an if right here and there is a condition we have a specific what we have a specific condition and then what when that condition is satisfied what's going to happen it's going to specifically what it's going to what it's going to execute the code that's here okay when the condition is not satisfied it's going to what it's going to skip it it's going to skip what the whole what the whole bracket to the very end it's going to skip it the whole what the whole code right here you can write hundreds of codes in the middle of this brackets but it's going to what it's going to skip it as long as what the condition is what not satisfied if it's satisfied it's going to what it's going to run it so I just want you guys to keep that in mind so why what are we going to do with this if Loop right here what are we going to do right here so let me go over right here okay to my screen the condition here is what if red right here if the set color is what if it's equal to Red okay if it's equal to Red here equal to it's equal to Red what does what do I want to do right here when it's equal to Red what do I want to do you guys know RGB so we want to get the most red color how do we get the most red color we do what we do this analog rights so let me copy the analog rights and I'm going to adjust the value again let me just remove this and let's just print this again and we have again analog what red pin 255 and unlock right Gren pin for what set we're going to set this to zero and the blue pen we're going to set it to zero because we only want what we only want red to be lighting up because what we want the color is what it's red so again we can again use our color Color Picker right here if you want to we can just go to Color Picker and say color sorry color RGB value RGB value of what value of red when we do that the RGB value of red is what 255 0 there we go so that's what we basically did 2055 0 0 I wanted to do it analog right for it 2055 0 Z right am I correct that's what I wanted to do what if it's not red so right here when it's not red when we want to set another condition okay now let me go back to my paper actually let me add another paper to be honest because this paper is not enough there we go so how do we set another condition okay we're going to be using something called else okay we're going to say if right here we going to say if and we have our condition okay and it's going to beun running the code if this is true okay okay then we have something called else okay else else as in what it's the second option else is what is more of what the second option so if this condition for example is satisfied what is going to happen it's going to run the code as I said but what if this condition is not satisfied if this condition is not satisfied I wanted to run let's say a specific code right here if I wanted to run specific code right here okay instead of just you know skipping as traditionally what did it do it had a condition and a code if it again this condition is not satisfied what did it do it just skipped it but let's say I want to you know if in this case this condition is not satisfied okay in this case this condition is not what it's not satisfied if in this case it's not satisfied what I wanted to do is write another what another type of code right here we have code number two right here and code number one I wanted to write code number one if this what this condition satisfied but if it's not I wanted to wrun another code okay instead of just skipping it I wanted to what write another code that's why we're going to be using something called else so what I want you to think of them is like this okay we had this again sentence right here which was what if it doesn't rain I will go outside to play basketball okay but something else can happen to other than raining let's say it gets too hot I'm talking really really hot so if it gets too hot what happens if it gets too hot what happens I will not go outside and what play basketball so instead of just about we're only talking about raining here we again it has a what a wider context because let's say it's what it's there's a tornado let's say outside if it's if there's a tornado or hurricane outside what I will not go outside and play basketball obviously I will not go outside and what play basketball so I just want you to keep that in mind so when you're working with else what are you doing we're just adding another condition we're just adding another condition just adding what another condition basically what we're saying is basically oh if this what if this code is not run it's condition is not satisfied I'm going to give you another option which is going to be you're writing down the second code okay so I just want you to think of it is that so if this what if this condition is not satisfied I wanted to do something else okay instead of just not playing basketball I wanted to do something else one of it would be what playing maybe board games okay so if let's say if it rains okay if it rains in this case what it's going to get be our condition is going to be what false if it rains instead of just not playing basketball what else am I going to do what also I'm going to do is what I'm also going to be let's say playing board games inside the house okay with my let's just say that okay so with that in mind okay you can say what else okay else and what I wanted to do is I wanted to tell our user right here I wanted to print out and tell our user right let me just go to serial do print and tell it hey color not recognized I wanted to tell it that we do not recognize what color it set right here okay I just wanted to tell it oh I don't recognize the color that you're just saying right here okay all right that's what I want to do okay so one final thing that we need to learn about if and else is to be exactly fully done is something called so we learned about if right here just recap we learned about if and then we learned about if and else combining them together and then we're going to learn about something called if right here let me start it's going to start like if just going to add up to it and there's our condition let me just give this separate this condition obviously we have our code in the middle of the brackets it's going to be code one then we have something called if else all right if else and we have a condition again we can write down another condition okay we're going to be using code two again right here and we can even set it up with what with else right here again right here else is what it's the final straw okay so here we go so what does this mean so this means is oh we have our code three right here when you see else we have our code three a third code there we go okay so what does this mean so this means is what if there is a condition what's going to happen it's going to be running the first code if this condition is not satisfied it's going to go to the second one we're going to give it another condition okay so we're going to give it another condition and it's going to be what running code two and what the third one is going to be what it's going to be running the final straw it's basically what the final straw it's like the final you know like the final thing that you do when you have any don't anything else you don't do right you don't do anything when you don't have anything else to do when you don't have uh anything else to do it's like the final straw okay it's going to be running what our final straw right here so I want you to keep that in mind so there's if again condition with the code one and there's if else condition and our code two and then what else and then our code the third code so I want you to keep that in mind okay so right here let me just bring my again our simple example right here I think it's going to make it way easier so what does an if else fit right here so basically thinking of it as I said again if it doesn't rain I will go outside to play basketball ball all right so in this case let's say it rains okay when this code is not satisfied it's going to jump this one and what's going to happen is if else it's going to go to the if else right here the second option it's going to be the second option it's going to go to our second option and say okay it's raining what else can I do what else can I do okay I will not go out I'll what I will not go outside to play basketball that is true I I will not go outside to play basketball but what else can I do I can be on my phone let's say okay let's say what I can be on my phone I just want you to think of it as what I will be inside of my house and be on my phone okay all right then let's say again there's another condition where this one cannot be true basically let's say there's no light and my battery is dead okay let's say my phone battery is dead in this case let's say my phone battery is dead as a final straw what do I do I play board games because I have no nothing else to do that's what I want you to think of okay so when this condition is not satisfied there's what there's what when this condition is not satisfied have another condition that we're going to do but when that condition is again not satisfied we have a final straw again to do what to do our last thing okay so let's say even we don't have board games well let's say this is going to be another if else okay we don't have a board game what are we going to do okay we're what we're going to do is maybe sleep because what we have we don't have any bird game we have we don't have anything to do basically we don't have anything to do we're just going to go to sleep okay just going to take a nap all right so that's what I want you to think of them okay so one thing you always need to keep in mind when working with these is what what it goes from up to top one thing you want to keep in mind is what it goes from up to top so again from up to bottom up to bottom so it's going to be reading the F right here so let's say it reads this one and this is true if this is true what's going to happen it's not going to read the else one okay it's not going to read it it's not going to read it it's going to skip it it's going to what it's going to skip it no matter what thing you're write in it it's going to what it's going to skip it okay keep that in mind when it comes to this one too what's going to happen is it's going to read the first condition if the first condition is satisfied what are we going to do let's say in this condition for example if what it doesn't rain what do I do I just go outside and play basketball I'm not going to be on my phone I'm not going to be using board games or anything I'm going to be what I'm going to be what playing out I'm going to be outside and what playing basketball so I want you to keep that in mind so when this condition is what set to true it's not even going to read the last options okay so it's going to pick from like these options and the first option is obviously this if it if it reads this and this is true it's going to skip all of this this okay so one final thing that you need to keep in mind is you can write down if let me Spring this here you can write down if and then you can write down what our condition again the condition then our code is going to be written down if we obviously what we we obviously write it down right here then we have if else okay then again it's going to have its own condition here and it's going to have its own code it's going to be code two then we can also add another if else the same thing it's going to run another code with another condition it has another different condition right here code three if else you can you can keep adding it to what till Infinity okay you can keep adding this to what to Infinity right here it's like adding let's say okay I don't have you know my phone is not here with me okay I'm going to be reading a book you know what instead of reading a book I'm going to be cooking some cooking dinner or something so what there's like infinite possibilities okay so you can keep writing down if else at what infinitely and then at the end what you do is always finish it with the last option it's going to be an else right here an else option and you finish it with a code so this is what our code for it's going to be our code five so one thing I want to again as I said is what always one if it is going to get picked so going to happen again when this is picked if the the first condition is picked what's going to happen if the first condition is picked what what's going to happen is basically what it's not even going to read all these if this is true it's not going to read any of these from else all of it till else everything it's not going to read anything it's not going to read all of it all right what if the second condition is true if the second condition is true what's going to happen Okay first reads the first condition and this one is false and second condition let's say treats it and it's true in this case what's going to happen anything beneath it is not going to be red it's going to be what it's going to be skipped anything beneath it it's going to what it's going to be skipped okay it's going to be keep going on like that so I just want you to keep that in mind we're working with um if conditions so I think it has been a very longer section of the course because we're learning about new uh uh programming again functionalities and all so it's going to be a bit uh it is a bit longer one so what I'm going to do is I'm going to stop this right now right here and then we're going to see uh we're going to take a break and then see you in the next section okay so in the previous section we discussed about e flops and uh now we're actually going to utilize them in our project so we're going to fully utilize them okay so let me go to my screen right here and what does this mean this means is what if the set color is red what happens the analog right command just go here the analog right command it's going to set the red p 255 obviously other ones are going to be set to zero basically giving us what the color red so let's see what happens when I just do that so let me just upload it right now let uploading and there's a problem right here can you see I do not write down anything on the what on the Arduino I not write down anything but what happened here what happened was it turned down to red which is a bad thing because I'm supposed to what I'm supposed to go to my serial monitor right here and then I'm supposed to type red and then when I enter it when I send it to the Rino then it should have been turning to Red not when I again just did not do anything right here okay so I did nothing and what happened was let me tell you guys what happened was I said the color is equals to what to red right here I said the color is equals to what serial. read string all right then afterwards what did I say if set colors equal to the red I set it to what I set it to read to Red so how do we compare things so how do we you know know the difference between setting up stuff you know just as in like this let me just bring this here to bring a paper and I think I'm going to use a math analogy again because to make things way way simpler for you guys so I'm bring a paper here okay so if you remember if you guys learned about expressions and then equations what is the difference right here when it came to Expressions what we have to say is what 5x + 7 is like an expression what is an equation an equation has the equal sign let's say 5x is 7 is equals to maybe here four okay so right here what does this do this means means to solve what does this mean when when we set the equals to here this means what solve for x in this case what if I said 4 equals 5 4 equals 5 if I say that this is going to be what this is a statement and what is the statement is it true or false this is definitely what this is definitely a false statement okay so we use the same sign right here to do what to solve for X and what to even what to see and compare and contrast so basically what we see what the statement to see the statement but when it come to computers I said that what computers are what computers take you literally and I think all of you know that that computers what they take you literally so they need to understand the difference between you are solving for x basically they need to understand the difference when it comes to computers right now they need to understand the difference when you're assigning a v a variable assigning ing a variable assigning value right here to a what to a variable they need to know the difference between you assigning a value and then you comparing a value with another comparing values comparing two values so how does a computer know when you're assigning a value and when you're comparing values because when we go to line 23 here what are we trying to do we're trying to compare the set color value iable with what with the string red if the string is equal to Red if the answer is equal to Red what are we saying if it's equal to Red we wanted to what you wanted to write what this code it wants to run this code you want it to run this code between line 24 and uh 26 okay that's what we're basically saying but it cannot know that so when it comes to assigning values one thing you need to keep in mind is when it comes to assigning values you're going to be using the equal sign just like how we're using again the equal sign at line 21 to what to set the color right here we say set color is equals to what serial. rring to assign variables you only what use what you use an equal side but when we were comparing values what do we do is we use two equal signs okay an equal sign next to an equal sign when we do that our ouro knows that we're comparing values okay so we're not assigning values we're comparing values okay that's one thing I want you to know okay so let me just move it right here and let me fix this properly after what right now I'm what in line 23 I'm I I'm doing what I'm literally comparing what I'm literally comparing so what should I be using I should be using double there we go I'm going to be using double equal signs here and then let's upload it okay I forgot to again close my sering monitor it happens often all right let me go again should be uploading okay it's done uploading there we go now everything is fine there we go it's not lit up right here okay so now what do we think should do right now when I say red we want it to turn to what we want it to turn to Red so let me just do that right here actually I keep getting color not recognize color not recognized color not recognized over and over again let's see why is this happening first okay so obviously this is going in a loop right here right here it's a loop the void Loop so it's going to check for the set color in this case I have not set anything so it's going to be an empty string or almost zero a zero or an empty string some somewhat like that because I don't not put anything right now let's see what happens and then it's going to be checking for the set color is equals to Red obviously it's not equal to Red in this case and then it's going to go what to what okay this is not true so let me go to this one let me go to the else one let me go to the else one it's going to say let me go to else one and do what and run this code again and then I'm going to start the cycle again because we're in what in Loop so that's the problem here so let me remove the else for now because it's quite quite distracting for now so let's remove else for now at least so let me just turn off the serial monitor right here and try to upload it okay it's done compiling and it should be uploading all right it's done uploading so let's see if we're even going to run to errors right now okay so right now when I say red when I enter red right now I expect this led to turn to what to Red so let me try to do that I'm just going to touch the ENT key right now and uh we can't see nothing let me try to doing it again you still can't see anything so in this case let me try to debug it all right so one way to debug it is what let me go to my uh serial right here and say serial. print it let's try to print the set color if there's even a problem with it so let me just check if the set color is correct so let me just upload this but before doing that again turn off my serial monitor let me just upload this right here it's done compiling okay it's done uploading all right now let's try to go to my serial Monitor and now let me try to go to my monitor right here and set the value to Red okay let me just try to do that okay it's not setting to red as you can see right here what is the problem again what happens it's just printing out I think an empty character there we go it's emptying out look at it it's going down and down if you look at the pointer but it's emptying out what printing out empty characters why is that so I don't put anything inside of the message again I didn't put anything inside of the message for an instance I only put what red for an instance and then keeps running and running and running again so I need to put it where I need to put this the print one I need to print put it right here I want it to print as soon as what it turns to Red I think it's better that way but it might not even print it because why is this a bad idea again m because if obviously this is true it would have run this so it always skipped this this basically means it always skips it it's saying that set color is not equal to Red for some reason and I need to figure it out myself so let me try to do is let me try to do is just go over here it's be before the uh before the color right here what I want to do is I wanted to read the string and then okay let's try it again I think it's better that way let's try to see it because it's really hard to work from here okay let me just do that okay it's done uploading so let me try to go right here let me just say red okay there we go there's an instance of red right here before I get it runs through it let me forget about the no line ending right here let me focus on the red right here there we go can you see it the red has a what right here it has a space can you see this it's like writing it as what the problem here is like it's right equalent of writing it as what as a red and then maybe you're putting a a new line right here you're giving it a space like it looks like this because it has what they said again has a space next to it so obviously this red is not equal to what it's not equal to not equal to what to the red we have again on the code right here the red we have here it's not equal to that what also could be happening is it could be doing this it could be saying is you know what it prints red in a new line all right it prints red in a new line it prints red in a new line either it's a space or it's a new line because I cannot extract that information right now can be a red or it can be a what a new line right here at the end at the very end there's a new line it's creating a new line here okay so let's see if it is a new line or just a space so that we can adjust it to what we can adjust uh our red right here the string that we have to again compare it to so what I'm going to do right here it's going to be uh you know what if it's a new line I should print next to it I should be printing something next to it so let me just print something next to it uh print not a new line let me just take off the new line right here let me just take off the new line for both codes and if it's a new line should basically what this one should be on its separate line again so let me just print out maybe then say hello okay hello all right hello there we go finish that so basically what should happen right now if it's know if it doesn't have any new line or space What Happens let's see what's going to happen the two scenarios the first scenario is what the set color what doesn't have any string so basically it's going to appear as what is Red by the way for those of you who have a legacy version it's going to appear it's going to work for you guys okay I'm going to get back to you guys so right here red okay it's going to here is red or we're going to be receiving what we're going to be receiving red with a space as we saw on the seral monitor it had a space when I selected on it and then or it might be a what it might be a red and it has a new line at the very end it tries to make a what a new line right here write that a new line okay that's what it's trying to make so how do I know if it's a new line or a space I received the one that had what again a space right here how do I know it's a space or a new line obviously what I do is again put a hello next to it so if it if it doesn't have a new line what's going to happen there's a space right here what it should it give me it should give me like red right here say after the space say hello okay but if it has a new line on on a new line on another line we're supposed to be receiving what hello on a new line on a totally new line so let's see what happens here let me just upload this again so again we might need to what we might need to adjust again this makes no sense as I said again it makes no sense why arino is doing this but again we just have to adjust okay all right there we go keep saying hello hello hello now let me try to say red right here look what happens there's a red right here and at the very end look what happens right now when I even go go to the very edge there's no space right here but it pushes this to a new line so what does this mean this means that what we're having a red that is attached to a new line so basically what does this mean is one thing that we have to know is what when we're using serial do sorry serial. print sorry what was it called read string read string okay when we're using serial. read string one thing you always need to keep in mind is what it prints out strings prints out strings okay and it prints it out in what prints it out in a new line okay all right that's one that's are the two things you want to know okay print it out in a in a string and prints it out in what in a new line one other thing too and prints it out in the string so one other thing I really want to show you guys is all right let me just remove this hello right here so that it comes becomes really easy to teach you guys this one when I mean that it prints out everything in a string I'm actually going to show you why what I mean by that okay so right here let me just right here okay if I write down 10 and if I print it out what's going to happen is it's going to give me a version of this so what I have right here what I gave Arduino Arduino is what the number what did I give it the number 10 I gave it the number it's a number 10 wait let me just let me go back here give it the number 10 what did Arduino give me what Arduino printed again what Arduino again set serial sorry there we go what set what color right here what was my variable darino set color again what did it set the variable again two is listen let set it to a stringed 10 okay a 10 inside of a what inside of a string so what does this basically mean okay one thing I want you to understand here is it it looks quite the same don't you look at it doesn't look quite the same but it does not behave the same why is that so because if I said right here if I said uh 10 right here let me say 10 + 5 and just you know write it down and let me just compile it okay I'm not going to upload it compile it right here I'm not I'm not going to have any sort of error but if I just do a string version 10 right here okay a string 10 and try to add it up with five if I add it up in five it doesn't seem like there's a problem but if I print it right here okay let me just print it print this and a new line I should be printing it in a new line let me just print this in a new line let's see what happens let me just verify it and then let's upload it let's see what happens when I add up the string 10 with five okay so as soon as I open my serial monitor it says comare is already connected okay let me just get back here let me try to unplug my Arduino and then let me unplug it back in okay now I think should be working let me just try to upload it okay so done compiling and I think should be uploading by now okay so when I go to my serial monitor I should be getting what I want to see what happens when we add up 10 and then five so let's see what happens when we add up 10 and five it's not printing anything let me just see if if it's even capable of printing something let me just say hello world okay let's just say that let me try to upload it take off my serial Monitor and it's done uploading okay it's not okay there we go give us her Hello World there we go so what I'm going to do is you know what I think it's not g to add it up just say 10 right here and I think it's capable of adding it up let just go right here I'm let just verify it this okay St compiling let me just upload it hopefully we don't go into an error all right nice now let's see what happens we still not receiving anything can you see it you're not receiving anything but basically what happens is we cannot add what we cannot add can you see we cannot add strings to what to numbers have you ever thought of adding up a number to a text I don't think it's even physically possible you know we cannot even do it theoretically it's not possible obviously it's what it this sorry uh does not obey the law of math obviously we cannot do what we cannot add a text to what to a number so basically we cannot add a string to what to a number but if I say 10 plus 5 right here 10 + 5 and let me try to verify it and let me just try to upload it there we go how about now try to upload it it's done compiling and it's uploading all right it's done uploading there you go it starts to give me what the number 15 the number 15 the number 15 10 + 5 is what 15 so that's one thing I want you guys to keep in mind okay so when you're working with the when you're working with again those serial R strings what do they do their name even gives us away what do they do they always convert anything they print out strings every time what they do they always what when they store values they what they put them in strings and what they do they print it out in a what in a new line okay all right so one thing you need to know before actually you know working with this before actually uh finishing up is what we need to make it we need to create a new line character we need a new line character so that it matches what this one right here right because right here set color is what set color is not only what we said it's a string what does it also have it has a new line it has a new line okay so it's not going to be equal to it's not going to be exactly equal to what to red again if it was a human being it would have understood obviously would have understood that these things are equal but when it comes to computers again they take it what they take it literally so it has to be literally equal if it's not literally equal it's not going to take it if I said red like this with a space is equal to Red it's going to say it's going to give me the output of what it's going to give me the output of false okay it's going to say it's false it's not true but obviously if it was a human what would they say say it is true obviously as we can what we can account for mistakes but computers to get they take it what too literally so with that in mind how do we represent the new line characters is the big question this one represents a space then how do we represent a new line well if you go and Google right here just Google it right here if you go to sln okay sln uino new line do we know new line it literally starts with a what with a back slash n can you see it it says slash n there we go slash n slash n okay that's one thing I want you guys to understand slash n so what you're going to be using is a backs slash so it's going to be uh B beneath your backspace or above your Enter key so there's a back slash and there's a forward slash okay don't use the one that is what a forward slash use the one that is what back slash okay so even though you let's say you do not have that character even on a keyboard let's say for example using an old keyboard and you don't have that character what you're going to do is just say backs slash say backslash if you just find the backslash all you have to do is copy it from here there we go we can do is what copy it from here again you guys can see right here the back slash is right around here okay so even if you cannot find it all you have to do is what copy this and paste it okay anyways so you represent it with a backslash and an N okay n stands for what for new line okay so let me go over here and let's try to upload it finally let's try to upload it and now I hope everything should be working because we went through lots of eras in this section so okay let's go to our serial monitor right now and let's see and let's write down red and finally it lights up what it finally lights up as what it's finally lights up as red there we go it finally lights up as red okay so that's one thing that's a very very complicated thing but let me explain to you guys why this is the case okay so let me go over right here so for those of you who are using an Arduino version older version by the way but an older version those leg Legacy verion that are 1.8 you're not going to go through this error it's going to work for you perfectly fine okay so if you just say red set color equals the red it's going to perfectly work okay but after um the ones that are using the neard weo right now at the current time of filming I'm using an Arduino uh let me just go right here the verion is is at the very top I'm using 2.1 there we go 2.1.0 so if you're using something uh around the two Series right here the ardino 2 2 point something series okay what's going to happen is what you're going to have to use the new line okay you're going to have to use the what the new line character okay so for those of you had uh again an older version The Legacy version which is 1.8 you guys all you need to do is what you guys only need to write it down as a normal string but for those of you there is what there's the addition of what there's the addition of new line every time so what does this mean by the way one other analogy we can use is actually a good example would be print serial. print and serial do what serial.println all right print Ln what did we do when we were using serial.print this basically means what it prints it out and it's next to each other that's what happened when it comes to print Ln what it did what it did was it just printed the serial first it was just a combination of what it was a combination of basically serial what do print and we added what at the very end we added the character what with the back slash right here again back slashes are important the forward slash back sln with the what with the new line character that's basically it serial print Ln was what serial print added with what with the what with the back slash and what character basically meaning a what a new line okay that's all I want you guys to keep in mind all right so right here we just only added red so let's add few more colors I think this is going to be the most exciting section of the course because uh we went through a lot of Errors before even getting close to here so let me just remove all these codes that are unnecessary all right there we go let's just improve our code right here okay so what else can I use right here what can I say if else or else if again let me go right here what I say we used if else if else if else if else again all right so how do we write down that in our doino let me just check that out say else if Aro let me just go over to an arino again you always have to what you always have to read documentation there's if there's else and there's what else if okay so the naming is different when it comes towards what type of language we're using but it's an if else or you can call it an else if it's again preference you can call it if else or else if but you have to write it down as else if when it comes to what tardo there we go we have to write it down as what else if I teach this as if else because I was using a different I use a different language to code and it's written down as if else in another language okay another coding language but right here we have to write it down as elsf all right so what I have to do is right here is say okay this is not red what I want it to be is what it's all right I wanted it to what let's use let's set up uh let's say this time let's set up um Canan actually I want to set up Canan I really want to set up C obviously give it a new line right here and then after giving a condition obviously what do I want to do now I want to do the analog right red pin version I don't know what it is I have to first I have to first what Google it so let me say Canan RGB value the RGB value of Canan is what red of zero green of 100 and a blue of 100 okay so let's just do that so let me go right here red of what zero a green of what 100 just go analog right green pin and give it a 100 value and then what analog right of what green sorry red blue blue of what 100 right here and let's set it up okay so I want upload it let me just turn off my serial monitor right here and I think this good all right it's good let's go to our Ser monitor right here okay we're going to upload it right now and should be working good let me just try to say right now let me just say red for now there we go have a s there we go changes to S hopefully you guys can see it let me just see if you can see it it's somewhat what greenish type of blue again if you can see it looks beautiful then you can add more colors too you can again add pink you can add what purple it's up to you again add your favorite colors this is going to be a project add uh three or four of your favorite colors and then fully create what I just did right here okay I just want you to do that that's not that's all you have to do okay so anyways uh this was a bit of a longer section a big a bit of a bigger project uh we finished it it was success so anyways uh see you in the next section okay so let's go to the section so right now what we're going to be discussing about today is Led displays so the seven segment LED displays so this is going to be our first time in this course working with some sort of display okay so this this display I think you're familiar with it as in we use it in digital watches not only digital watches but calculators and even when it comes to let's say we're going to a gas station to again fuel up our car we can see what we can see the price per gallon stated by these type of displays and even the total price being what displayed on what by using uh these type of displays so we see them very very lot often so what are their use their use is we use them when we want to what when we want to only get numbers or Alpha numerals these are capable of what only displaying Alpha numerals and numbers so for example we have LCD screen when it comes towards our laptops our uh devices and all that they have a dedicated display but what if you need a very cheap display that is supposed to only you know indicate number or sometimes letter so so in this case the effective solution is going to be what having these cheap LED displays again they are very very little not only that too but they're very very cheap okay so when we're using again when we don't want these smart L LCD displays again to again use them uh on devices that are unnecessary when they're unnecessary we use what we use LED displays so right here we're going to be using it so right here one thing you need to understand is when it comes to LED displays right here when you go over there is a specific number associated with your specific what with your specific manufacturer basically the one the type of what the type of LED display seven segment LED display so before doing anything what you first must do is literally go here Google the name right here say right now mine is 5611 as okay you have to go to my let me just go over to my screen right now so before running anything first thing we need to do is Google 5611 this again my number you you Google your own number seven segment display data sheet okay once you do that go towards the link that has PDF or you can go over and get the website check it for yourself okay so I'm right here and one of the things you can see what the size you can see the emitting col it's going to be red some of them are blue but most of them are red and it has a common cathode I'm going to get to this and it's obviously single digit and it gives me all the information I need on what on this what on this LED display the seven segment LED display okay so right here you might be wondering what it why why do we call it a seven segment LED display so let me just go over right here and when you just read this when you just look at the seven components right here let me just focus on the L 7 segment LED display when you look at this when you count this let me just actually use a pointer get my Sharp you right here when you look at this when you count this it has seven segments count it if you count it there's one two 3 4 let just focus my again my camera on the LED display five 6 7 there are seven okay and it also has a decimal point my one has a decimal point yours might not have a decimal point included but most of them do okay so it's going to vary as I said from kit to Kit so again know your number and read your sheet okay so before moving forward I just want to declare something called common capod and common anode so they come in two again they might seem the same as I said looks can be very deceptive they seem exactly the same but they function again entirely differently okay so there are going to be two types of what led seven segment displays so this are going to be common cathodes and then common anodes okay so right here as again let me just go to my documentation to my screen when I do that it says that it's a what it's a common cathode mine is a common cathode so what does this mean so let me go right here and try to explain it for you guys with this image okay a common cathode means is that there are different as you can see all the segments the seven segments are right here there are seven segments and then the decimal point right here and what basically happens is what they are connected to what to a single common cathode okay they're connected to a single what cathode so you can see they're individually right here they have their own individual pins as you can see let me just go over to just go over right here and show you in my camera they have their own what just focus on the there we go they have their own pins as you can see right here here they have their own pins okay and then what happens is inside they're connected to what they're connected to a common cathode that's why they're called what common cathode seven segment LED displays okay when it comes to the common an exactly it's exactly the same thing okay it's exactly the same thing what happens is what it's connected to a what it's connected to a common anode okay this time you might not know what anode and cathode means but cathode Bally means negatively charged anode means what positively charged so to actually give you guys a a meaningful sentence what I'm going to do is draw a simple circuit as we usually do let me just do that the longer side is the positive as we know the shortest side is the negative and let me just draw that okay then once I'm done drawing it there's a positive side and there's the negative side side the positive side is what the 5 Vol keep attention and the negative side is what negative side is where the G and D okay so when we say we have a common cathode what do we mean we have a common G and D pin okay so for example my case it's a common cathode I'm going to have what I'm going to need only one g& D because why they have it all in common so it's connected together so again they're connected together at the very end and they have what one common what one common g& D pin when it comes to the anode it's going to have what one connected 5vt pin okay so I'm going to try to go over both of them both common anode and both common cathode so we don't have to go through any other videos you can just follow along this course okay so let's get started so let me just bring this right here let me just put it and what I'm going to need you to Google is right here go to seven segment LED display write it down seven segment LED display right here once you do that go to your Google images okay and they show you the equivalent one the equivalent pin so let me just go over to this one this one looks better this one provides a more detailed image there we go so what can you see right here it say GF a b basically indicating which segment it's going to it's going to what it's going to light up okay so G indicates what this one so the first one that is at the very very left right here at the very very left is what the very very left is what it's G then the next one is f and the ones that are marked with again an underscore a Hy you can see right here are the common grounds okay they're the ones that are going to be what those are going to be G and D if it's a common cathode and 5 volt if it's a common anode okay I just want you to keep that in mind and a and b and there's e d c and also d right here okay so with that in mind let me just try to light up my common cathode uh LED let me just do that let me just bring my LED right here what do I need I need resistance right here by the way it's recommended that you use 500 to 1,000 ohms of resistance okay so 500 to 1,000 ohms of resistance the resistance is going to be applied to who the is going to be applied to every individual pin okay except for the what for the common anode or for the common C Cod okay except for the common cathode and common anode we're not going to apply the as I said again we're not going to apply the resistance but where we're going to apply it is we're going to be applying it to every individual what segment okay let's just keep that in mind okay so let me just do that and bring this oh just threw a resistor I'll try to find it later anyways um so right here when I go to my the screen again it's going to be my guide okay the G is located at the the very very what at the very very left let me just again unplug my adino so I can get it closer and all I need to do is what connect the G right here let just go over right here so you can see it I'm going to connect the G and then I have a wire let me just get a wire right here okay I have a wire right here okay but first let me connect the common one what do I have I'm using what a common cathode so it's going to have what when I'm using a common cathode it has what it has a common gnd D let me just connect that the gnd D is found in third leg so let me just do that so let me bring a black pin for the gnd D let me bring a black pin right here count one two three and here we go there we go connect this to the gnd let me just do do that and what I'm going to connect it to is a what I'm going to be connecting it to a pin right here let me just connect it to 5 volt for now just to show you how it works but I'm going to be connecting it to a pin when we're working with a project so just to show you how it works let me just connect it to a 5vt there we go connected it to a 5vt and now what do I expect the G the G to to light them the G's found in the middle it's the middle segment it's the middle segment so I expect this to light up okay the resistor should be intact I'm using a 1,000 Ohm resistor you guys can use anything between 500 and 1,000 Ms and this should be working hopefully okay can you see that can you see that what's happened the common the common uh sorry the common capod is right but what happened was what did I do wrong I got the decimal point light up up instead of what instead of the the G what did I do wrong what did I did was I flipped it okay what I did was what I flipped it I was supposed to put it like this supposed to flip this like this the decimal should be here and then put it down like this first let me unplug my adreno because again I don't want to get the Pence wrong right I think there we go that should be it excuse me all right so now let me just plug back the ardino there we go now it's working let me just turn off the light so you can see it better there we go the middle what the middle segment is lighting up nice so now let's just go to the ones who have common anode let's see how you guys can actually do it let me just check that and in the next section we're actually going to build the project with it so let me just go over to my screen again because I don't have specifically I don't have uh my own I don't have a just go to my Tinker C right here specifically I don't have a I don't have an anode a common anode seven segment LED display so I'm going to have to use a digital Ardo just creade that it's going good now what I'm going to need is an ardino get an ardino there we go what else do I need a breadboard breadboard I can get a small one for now I'm just trying to light up what a single display then we're going to go to our project okay and then what do I need I need uh a seven segment let just write it down seven segment there you go seven segment not getting anything just seven segment there we go seven segment display okay so I'm going to set it to what a common anode right here so you guys can actually see how it's done so as I said again a common anode what do we have let me just bring back the paper I'm not going to need this anymore let me just bring back the paper common anode we can have a common 5vt pin okay so let me just connect the common one right here so I I said again we have one thing to always keep in mind by the way let me just go to the image do we have the image okay there we go all we have to do is connect one of these again common PS okay one of these we going have to connect both of them okay we don't have to connect one 5V and another 5vt all we have to do is connect one of them okay all you need to do is what connect one5 Volt or one 15 volt when it comes to a common anode when it comes to a common cathode what you need to do is what connect what um one common what gnd D not like two G&S all right so you can choose either one and just connect it okay all right so with that in mind all you need to do is I'm going to connect the 5 volt right here to the third leg third one is here the comment there you go once I'm done doing that I'm going to use a resistance on the gnd D let me just get a resistance let just get a resistor resistor there we go got a resistor what value 1 kilohm basically meaning 1,000 ohm let me just roll it let me just rotate it so that it fits me let me try to light up a different segment here let me try to light up this one I don't know what what this one is it's B which one is B let me just see which one is B okay so I'm going to be lighting up this part I'm going to be lighting what the right one the right the right upper one the right upper one okay so let me just go here and I'm going to need my I'm going to be using what I'm not going to be using g& D don't get that WR wrong okay I'm not going to be using gnd D I'm going to be using distal pins yes I can use a gnd d for now let me just try to use a gnd d for now let's see what happens never used the gnd with that yeah let me just just land it on gnd D see what happens actually I think it should light up there we go it lights up as you can see it it lights up so we're going to do again uh so right now what we did is can light up a common anode and a common cathode so for those of you again who're going to follow along with a common anode I'm also going to again provide you with the course right here so you guys do not need to again go to another uh YouTube video or another another documentation to understand because I'm going to be covering both common anode and common cathode okay so in the next section we're actually going to build a project so um see you then okay so what do I want to do for this project what I want to do for this project is build somewhat of a simple timer so I wanted to count from nine all the way up to zero so I wanted to go 9 8 7 6 5 4 3 2 one and end it at zero okay so we're just want to build somewhat of a what personal timer okay so first how we do that so first what do we need to do we need to plug all the components here obviously we did not plug any components and then we're going to go over to code so let's first plug our components okay so again as I said the third one the third one is what the third one is the common ground here for me it's a common cathode so I'm going to be what using what a common what a common G and D okay that's all we said all right so let me just get this over with and just bring this there we go so instead of using normal wires what I'm going to be using is strapped on wires wires that are strapped to each other so when you look at them they're strapped to each other it makes things way easier for me as all I need to do is what connect connect it continuously and then what and then all I have to do is connect it continuously here too so it's going to be way easier than using again normal wires okay than using normal wires but if you don't have any of these strapped uh these strapped type of uh wires the normal wires are perfectly fine they don't make any difference in terms of conductivity or anything only the only reason I'm using them is I want to introduce new components too I only that too but it makes it way easier because once I put them right here let's say I set up the five pins that I'm supposed to be connecting here once I set up the five pins right here all I need to do is what see it relatively from here so I go Brown is first okay Brown is here and you know and go right here Brown is here and then relatively tell what the distance from here I don't have to go the whole way back here just to tell which pin is connected to which pin so it makes it way easier especially when connecting what when when connecting wires that are closely to each other right here I have five pins to connect to just check it right here five pins right I've got five pins to connect to right here and five pins from here too okay so let me just get started so let me just arrange this so that it matches the color there we go right seems to okay purple needs to be in the middle right here all right there we go simple Arrangement now let get started so let me just start with brown right here all right what what did I do wrong right here I forgot to put my resistors first resistors do what they come first okay so obviously I have to connect my resistors first and then I'm going to be connecting my wires so let me bring my resistors right here again I'm using 1,00 ohm resistors okay I have a collection of them 1,000 ohm resistors but again you can you guys can obviously use anything between 500 to 1,000 okay so it doesn't directly have to be 1,000 okay so let me just put this here what I'm going to do is I'm going to move the resistors across okay that's what I'm going to try to do right here there we go try to move it across now let's connect the first one right here just focus here there we go it's connected now I keep on bringing res resistors first let me connect all the resistors and then I'm going to continue and connect it to the wires let me just do that okay you see what I did right here I connected a different the second pin but obviously they ended up in the same row so all I need to do is again widen it a bit and there we go aim for it okay I pushed it a bit there we go come on it's a bit of a hustle to actually connect them when you have a little amount of space okay so it did connect yep did connect right here all right nice now I'm going to bring another resistor let me try to find the one that is wider let me just widen it up myself all right now the third one what am I going to do to the third pin as we said again when you look at the diagram we have two common pins all right we have two common pins this is the third pin right here it's going to be the common one the third pin right here just point it using my resistor it's going to be what the common the same goes here too it's going to be the common so again when it comes to the common I'm not going to use any resistance I'm going to be only using resistance for what for the separate segments here all the segments so let me skip the third one I'm go to the fourth one okay you need to be really careful not to connect the wrong PIN the WR resistor to the wrong place everything can go wrong once you plug it once you plug your Arduino if you don't be careful okay wait slowly let me let me weiten this a bit all right there we go now let me just check it okay when you look at here I connected one two I skip the third now the fourth is connected and the fifth is connected and all of them are not in the similar not in the same row I just want to keep that there I don't want them to be in the same row okay all right they're not in the same row now I can start using again these pins so let me just do that we just go here it's a bit a hard one when you're picking it the breadboard up it's really hard all right there we go connecting to the first resistor here and then the next color is white let me go get white okay I need to go here all right the third color is silver let me get silver okay let me just see that you guys can actually see it there we go can you guys see it there we go connect the third one and the fourth resistor the fourth and the final resistor from this side right connect this one obviously what did I not do right now I did not connect my g& D pins so let me go over right here okay let me go over where's my gnd D pen let me just bring a separate wire for gnd D okay I'm just going to bring a separate wire it'll be preferred if I again bring a black one because we use black wires to connect gnd D just to maintain the code if I can I have a long black wire trying to look for one okay there are no black long black wires so I'm just going to use blue I cannot find it or I did I think this one is this one is long okay there we go found a black long wire so I'm going to connect the G and D let me just do that it's supposed to be one two it's supposed to be right here okay it's a bit of a hustle again let me connect this to the GM D we have a common ground pin just connect it to it all right there we go connected it to gnd all right now obviously we have a wi from other side now I don't have enough space here as you can see I only have one row of space right here I have one column of space because I said again this LEDs this led is Big so what I'm going to be doing is creatively I think a creative idea is to use use a smaller breadboard so I'm going to be connecting it what with the resistor across here and then I'm going to be using a smaller breadboard and connecting it here it's better that way so let me just do that so let me forget about these wires right now just put them right here uh let me just make sure that I have the numbers intact it has numbers on it so I'm going to be referencing the numbers right here on the breadboard let me just bring it Clos so you can see it there you go they have numbers 1 two 3 and I want to again reference this one okay so let me just do that just take off this one for a moment it's a bit of a hard one okay connected our first resistor then our second resistor we're not going to be using the common as I said again we're going to be using one of the common pins so as I said again we have two common pins and we have two common pins but we're going to be using only one okay so you either can use this one or you either can use this one you don't use both of them so right here I'm going to skip it I'm not going to touch any of it okay I already connected the g&d from this side so I don't need to connect it from this side so the third pin is going to be skipped totally okay now let me go to the fourth one the four line right here all right have to push it a bit they're a bit hard resistors to put in just let me first just straighten now myself okay just make it straight focus on the resistor for now let me bring it closer and actually focus on the resistor there we go you know what I'm going to do is straight on out once I'm done studying it out I'm just going to do is bend it okay there we go bend it there we go now let's focus on the on putting it back in because this said again the resistors they do not fit in properly sometimes and it can be a big of a problem this did not fit the best I think it's going to cause me problems but I think it fits actually I think it fits but might cause me problems in the after a bit while so let me just bring my final resistor connect it okay I'm going to connect the Fifth Line into the fifth pin there we go can you see it I connect the fifth one I cannot pick it up as I said again because there is side going to fall apart so I'm just going to move it very very slowly to the middle so you guys can see the frame right there we go just need to be very careful with it okay now I'm going to be connecting this blue wires as you can see I don't have enough what enough length to go here so what I'm going to do is just going to move this totally so what I'm going to do is from purple to Blue there's what there's a difference in so I have to change my Direction so what I'm going to do is wrap it more can you see this I'm just going to separate it can be separated there we go slowly can you see me I'm separating it I don't want to separate it completely if I do that then it's going to be useless there we go so it has more space I want to move a bit of the resistors I don't want them to move that much there we go we got our first then we need our second what comes after blue green all right let just use the green there we go third one is going to be orange or actually yellow yellow's the next one not orange I can see it for I can see the colors from here so it has to be after green has to be orange sorry yellow so I'm going to bring yellow not orange see that well that's why it's very useful it helps me again okay I'm going to skip the third pin and go to the fourth one it's very useful because I can just reference it from here they're attached so when I'm using a lot of pins I can just when when they're put next to each other I can use this type of wires because they make wiring way much easier because if I just wired them with this normal again wires I'm going to come back here check everything track back everything like this and then see where they're connected and it's going to be a bit of a hustle okay so I connected these four I skipped the third one and I connected the fourth all right good I don't want to move it too much it's moving a lot I don't like that not a big fan of it moving the resist don't seem to be holding them in place because they're weak wait seems to be moving a lot okay so what I'm going to do is separate the wires again I think the wires are just having a lot of tension on them but actually I can keep it like this to be honest because yeah I can keep it like this if everything is intact let me just check it everything seems to be intact so I can keep it like this actually but I just need to be careful when I move the wires again when I flip this we just slowly flip it ooh it's moving a lot all right I'm just going to try to flip it all right let me just connect to some random PIN so that it holds together I'm going to come back and solve this I'm just going to connect it to some random pins again obviously don't turn your arrina while you're doing this it's dangerous can just short the circuit right here I just connected it so that again it just moves okay I just connected it randomly all right just make sure that your aring is not turned on when you do that okay so right here let me just think of the pins that I'm going to be using I'm going to be using digital pins okay because I said again I'm going to be using digital right right here I'm going to be using digital right so I'm going to be using digital pit so I'm going to to use this side this is where my digital pins are so I'm going to be using the digital pins so again slowly doesn't seem to be holding the best wait wait let me just put these right here so that it doesn't move a lot I'm not going to be using them but again just so that it doesn't move a lot and holds it in place okay there we go all right so let me go over to the other side it's a bit of a hustle let's go over to the other side and now try to use these spins so I connected what purple pin so I need to get my purple pin first purple pins black pin all of these that are here I need to First them up hold this together okay so let me start with the black pen I'm just going to start from digital pen three okay you might be wondering why I'm using digital pin 3 instead of digital pin one why not start with digital pin one might be wondering well the thing is they're still pin one and they're still pin U zero they're also used in binary so as most case as possible I try to leave them alone okay I don't I don't try to touch them as much as I can but obviously you can use them for digital pins but they're also used for binary so I always again reserve them so I just don't touch them okay because just think of me filling up digital pin zero and one and let's say I want to use binary then I'm I'm have to arrange the whole thing again okay so I just leave them alone most of the time but they work as a normal dish to pin okay so again you guys can actually use them but it's just again not a practice as much as you can don't use them if you have to though you can use them they're perfectly fine to be used let me start with digital pin two digital pin three sorry I said digital pin three this hard to even see it three there we go after black what comes after black white ifal pin B then what comes after white gray I'm trying to get the gray there we go and then after gray comes [Music] purple there we go then afterwards after after uh purple comes blue which is right here let me go get it then after purple comes green let me just make sure that I not skip anything there we go got yellow then at the final one I have what I have brown obviously discluding the uh again the gnd D or the common pins I have what pins how many pins to connect I had 10 pins to connect and again discarding dis disregarding two common pins it's going to be eight pins so let me just count this if I'm correct one 2 3 4 5 6 7 eight so I connected eight bins let me just make sure the white is the yellow's connected properly there we go and now everything is connected again I just need to be more careful okay again I'm using this again as a support they're not connected to anything just keep that in mind don't want to move them bit I have to move them a bit right I'm not going to touch it afterwards there we go let me just bring my ardino wire hold there we go I'm just get my ardino wire let me wire up my adino just bring the wire let me just keep it here okay it was a bit of hustle to again even connected okay so now let's start writing down the pins let's start giving them names okay let's begin so go right here and give start giving them names okay so the first pin that we're going to be giving out name to is pin three first things first again we need to understand what part is going to be lighting up okay so be first I'm going to need what I'm going to need the diagram just get the diagram I say seven segment LED display let's go to images and should find a diagram that has there we go we find a diagram that has what their namings okay so let me start from here the very most left from here from this side it's going to be what the very most left side is what it's going to be the black one the black wire the black wire is connected to what to pin number three okay it's connect to pin number three what is it decimal point so what I'm going to say here is integer DP what is it it's pin number three integer what else is there and keep comparing them so what I'm going to do is going actually there we go divide them into two right here so you guys can actually see them let me just get the image let just get the image the full image let just open the image open the image UT tab let's get the whole image there we go all right so now what iConnect the decimal point then afterwards is white pin white is connected to what to pin number four which is what is it it's C so all you need to do is what C is of course to pin number four then integer again keep saying that then we skipped it and then we went to what we went to the silver one which is going to be D so D's set to what pin five it's going to be easy after e set to what pin six because they're set to what to next each other okay then afterwards what I need to do is we're done with this row so I need to go to the other one we need to go this side so we're going to need to check this one too okay so the blue starts at the very left the blue starts from here as you can see the blue starts from here it's connected to the very left okay the next after uh purple is what is blue so it's going to go after six it's going to be seven so this one is going to be seven okay so the very left again you need to keep referencing what the decimal point is how you're going to be referencing it okay so let's look at the image so is it going to be what it's going to be pin what segment what segment B it's going to be segment B what do it said to pin seven keep going on and then a set to what eight then afterwards again we skip the third one the common pin and then we go to F which is going to be set to pin nine and again the final one G set to what it's set to pin 10 so let's even see if it ends on pin 10 and starts at Pin three let me just look at it it's a bit of a hard one if you cannot move your Arduino it's really hard to actually look at it okay back pin 12 11 okay it's really hard to actually get a hold of these let me just look at it so again let's see if I made a mistake or not let me just move it slowly see that I stopped at Pin nine not pin 10 might have made a mistake here we connected four pins here and four pins here how much should it add up to I'm supposed to be using what eight pins okay how many integers did I set up eight integers I'm correct on this one did I start from three or two maybe I might have started from two let me just check it it is connected to pin it's connected to pin 3 or pin two it's connected to pin 3 I'm checking it and it's connected to pin three pin four five 6 7 8 n and then it doesn't seem to be connected to pin 10 did I forget about let me just check the number of pins that I connected here okay so I think I made a mistake right here because supposed to be extending to pin 10 and it's not touching pin 10 so let me just count the number of pins here 1 2 3 4 5 6 7 I'm supposed to be connecting eight pins so I did a mistake right here I made a mistake right here H what could it I made a simple mistake most likely so let me just check again all I need to do is what since they're what since as I said again they're connected pins it's going to be really easy when I make a mistake so let me just check it right here so I connected I don't not connect the green pen because I'm sure I connected okay there we go I connected green pen but I connect green pen so what did I do I connected Brown pin here instead of Green ooh just so wrong again let me just all I need to do is check it so let me just check the colors I connected black and then white and then gray which makes sense and then purple if I'm correct there we go connected purple and then blue and then yellow blue and then yellow but I forgot about Green in the middle right here I'm not conect I'm not supposed to be what connecting green right here I'm supposed to be connecting green not yellow oh I made a mistake right here that happens we just try to solve it there we go made a simple mistake but it was easy to solve why is that so I'm using attached pins that's why they're very very important as things get complicated it's going to be really really hard to fix them it would have taken me at least 10 minutes to even find the problem if I was using normal pins but with just using this pins I just made it really really easy okay and then what after green comes yellow now am I correct again did I make a simp another mistake okay now it's connected what how many pins one two three three four five 6 7 and then I have an orange pin did I connect an orange pin here yes I did but I connected it to what ooh instead of connecting this one see what I did wrong here instead of connecting an orange pin I connected a brown pin here the brown is the very very edge I'm not supposed to do that again so I made a mistake here let me just solve that remove the brown and what is next to Yellow it's orange I'm supposed to be connecting orange I made a mistake my bad and there we go now I fix it and now I also connect the orange from this side okay now everything seems to go okay everything seems to be right all right let me just again connect these two pin so that they hold the small breadboard together just going to kind of here so that it does not move a lot again they have no purpose of than holding the breadboard the red and the brown pin okay so now I think the wiring is right and now I set up what everything the name is Right extends to what to 10 from 2 to 10 so everything seems to be correct from so I said two I me three 3 to 10 so everything seems to be right so now let me go over to my code and now let me just go to p P mode and set everything up pin mode and set everything up so we have decimal point set it to what set it to Output all right keep copying this alternate shift down keep copying it and then I can do what I can change the names so I'm going to start with CDE let just go C and then there's d and then there's what there's [Music] e and then there's B just go to B and then there's what and then there's a and then there's F and then there's G okay let me just remove the final one let me just count the pins there're supposed to be eight one let just count it one two 3 4 five six seven eight they're eight pins okay good now what I need to do just to light up everything I'm going to need to do is what use digital write okay and send my pen right here let me just start again decimal pin and set it to high once I'm done with that for to light every component right now what do I need to do again I'm going to need to write the disal right I'm I'm going need to copy it it's going to be second two 3 4 five 6 7even eight okay now where do I go now let me write them down CDE e c d e and then after e there's ba a b a f and then finally G there we go so now let's just upload it well before I need to upload it though what do I need to do I need to wire up my Adeno so I'm going to move this again slowly it's going to be a bit of a hustle because if things go wrong right now and the resistors go wrong it's going to be really really sad because the amount of what wiring it took going to attach both and slowly move it again need to be gentle very very gentle because this resistors again can just pop out really just push it a bit okay now let's just try to turn on our adrino okay now let's just verify our sketch let's do that verify my sketch hopefully everything's good okay it's good now what now I can compile it's compiling and now it's done uploading okay can you see it it's not fully leading up uh just need to move this a bit okay just going to move it a bit so you can see it the wires there we go let me just focus on them let me just turn off the one light right here so you can focus at it not everything is turned on why is that so it's the resistors again let me just if I touch one resistor right here look at it if I just touch one resistor lights up it's because the resistors are not what connected properly okay so let me just again push the resist a bit there we go push this one in this one is pushed improperly everything seems to be intact here all right okay let me just check the other resistors right now oh there we go can you see it the second resistor is not connected properly slowly we need to go slow just push it okay there we go how about this one the gpin I think it's the very left one because I put it at the very edge it's not lighting up okay this pit right there we go let's push this it's a bit of a hustle let me try to push in this one and what what is not lighting up what segment is not lighting up right now okay this this segment is because of this resistor this resistor seems to be working fine how about this resistor okay both of them okay I see so again wiring it up is a big problem if itself especially with this resistors they don't hold and place and I find it really hard can you see that okay so they're not holding in plus two so what I'm going to do is again fix the resistors this resistor let me just see if this is even correct because not all of them are on just again so you can see that not all of them are on so for those of you are using a digital art we know it's going to be really easy for you guys it's going to be way easier than here again due to the limitation we have again and components we going to have to find a way to work around it okay everything seems to be working fine but the middle pin right here let me just check what is even the name of the pen let just check the name of the pen okay so let me go to my Chrome the middle pen is the gpin okay where is the gpin which one is connected to the middle pin how am I supposed to know that uh let me again check the image G is supposed to be around here okay G is around here at the very edge the very edge but the res at the very edge is not working basically let me just check if it even if it's wired up correctly I'm just need to remove this it's not doing much of a thing slowly okay let me just again straighten out the resistor hopefully you can see it let just bring my light out make a focus on the resistor the focus is bad I'm just going to straighten out my resistor just focused on the LED right now okay straight it and out there we go now I'm going to have to carefully put it back in just again a hustle just do that oh I see the problem here too I do not push it in let me just push in my L just push it in first there we go now it's pushed in our LED is pushed in only what only one line is not only one line is missed right here can turn off my light so you can see it better only one line is not is not appearing what is it it's the line F which is going to be next to what next to G so the res next to G is not lighting up properly let me just check why it's not lighting up properly I'm just turn on my light right here it's a bit of hustle as I said again oo I's see what the problem is there we go push it in and then slowly let go slowly let go let me just turn off both the light so we can see what we did right here it looks beautiful okay turn it off and turn it off for let me just turn off the other one there we go now everything is lighting up including the what the decimal point all right nice okay let me just go right here and do exactly what I just did I'm going to light up two three pins on the common anode I'm using a common cathode so I'm going to show you guys how to do it in a common anode just in case you do not know okay so let me just go right here this is a common an that I said just turn this off let me just take this off let me delete this first where's the delete button there we go just let me just first bre it and then there we go delete this delete the resistor so basically what do you do is what we have a common what we have a common this is a common anode so what do we do we have a common what I have a common 5 volt so what I'm going to do right here is connect the 5V right here the common 5 volt to the third pin again I can use the one that is at the bottom right here or I can use the one at the top it's up to me there we go now once I'm done connecting the 5 volt just give it a color right here so that it's easier to track again okay and just change the color right here to Red there we go the 5 Vol and now I'm going to start connecting what I'm going to start connecting using resistors so I'm just connect uh one let me just light up one two three segments and then I'm sure that you can do the rest of it okay I'm sure that you can light up the rest of it so I'm me just go right here it has a resistance of 1 kils okay basically 1,000s and now let me just rotate it just rotate it right now okay so you might be wondering how to turn it on using a digital pin all we did was what there's the five volt in the ground pin so I'm just going to show you guys how to use a digital pin and just light it up okay another resistor here let me slide up this part too okay just rotate it right there we go let me start writing code for this so uh before doing that actually I need to what I need to connect the wires so I'm going to connect this wire right here to digital pin three let me start from pin three just give this another color let me start with orange go and let's give this another color too First Connect this to digal pin 4 there we go give it another color so you can see way better I'm just going to zoom in so you can see the circuit way better okay there you go that's the circuit that I'm going to be using you can pause the video and check it for yourself okay all right now let me just go to the code so what you need to do is basically the opposite when it comes to what when it comes to the common what the common cathode okay so I'm go text and use text so what I'm going to do is let me just again set up variables I want you to do it yourself for those who have common anode I'm sure you guys can do it just have to follow the same step but there's going to be a difference I'm just going to show you the difference here okay that's basically what you need to do um let me just bring the seven segment where is it the seven segment image I'm going to be connecting B right here just see it it's going to be let me just take off the code for now I'm going to be connecting B and and from underneath here I'm going to be connecting what I'm going to be connecting the decimal point okay let me connect the decimal point and B very is b b is around here so I'm going to be lighting this and this up okay so let me go to our code then what let me just turn off all this code right here I don't want that so I'm going to say B what what what pin is it it's pin three let's connect digital pin three and what do we have decimal point it's going to be connected to what to what the digital pin 4 then what I need you to do is what right here set it up as we did normally set it up pin mode set be to what the output just get the capitalization right pin mode set the decimal point two to what to Output output there we go and all you need to do right here is instead of using Dish right again you're going to be using digital right and setting it to high what you're going to be setting it to is low okay we're going to be setting it to what to low basically almost acting like a what it's going to act like a g& d pin okay so I'm going to do decimal point and setting it to low I set again so let me just start the simulation right here and let's just move our code and there you go B and decimal point is what they're activated so what I want you to do again to light up everything is what again connect all these components yourself just like how I did using my common cathode again connected and then write every code obviously for Tom and Anna you're going to be using what you're going to be setting it to low okay that's all you need to do instead of high you're going to be setting it to what to low okay so just keep that in mind so now what I did is what what I did is set it up to what to light up everything so to even make a timer right now let me go over to my arino IDE let me go to my IDE there we go so now what do I need to do I want to set it to what I want it to count from nine then go to eight then go to 7 6 5 4 3 2 1 and then finally going to what to zero okay that's what I wanted to do so again I turned all of this just to check that everything is connected I turned out everything to high just to see that they're connected and now they're successfully connected because everything's on I just wanted to check if everything is on so that does not give me does not cause me problems later on okay oh I just turned off the pin mode sorry I was supposed to uh Delete the high ones accidentally I accidentally cut this sorry I just put it back uh I want to do is what take off the digital rights not the pin mode pin mode I needed it's a bit of hard there we go there we go now for n what do we need to light up for n we need to light up what so let me start from here I just copied this okay okay I want you to do is what before cutting this okay I want you to copy it again that I set it all of it to high I want you to copy it and going turn it off right here what I want you to do is for night what segments do we want to light up so we go over right here we want to light up what we want to light up where is nine there we go for nine we're going to need to light up what a b g c and d a b g c andd so what I'm going to do right here is bring a paper I think it's going to make it way easier let's first write it down I think it's better that way so I'm just bring a paper right here BR some paper just go get it there we go all right there we go found the paper right here let me go get my Sharpie the Sharpie there you go found my Sharpie I don't want to push this a lot so I'm just slowly move it because I need that space Oh my God it's very very very very hard just moved it a bit and the pin B just turned off there we go just push it back in okay there we go okay so for nine what do I need what do I need to turn on for nine let me just keep writing this for nine what do I need to turn on I need to turn on a b g c d so I need to turn on a b g c and d let me just make sure again a b g c d all right for eight what do I need to turn on for eight I need to turn on everything everything from what from a to G I'm going to need to turn on all of it I can add the decimal point but I don't need to all right so for um seven right here what do I need to turn on I need to turn on a b c a b c yeah a b c for uh seven then six let me write the numbers down for it's easier that way one then end it to zero okay for for six what do I need to turn on a f g let me first go a f j a f g and then e c d e c d basically turn on everything except for B then go to number five what do I need to turn on I need to turn on afg afg AF FG and then CD just write that down CD for number four what do I need to turn on for number four I need to turn on uh fgb just write that down FG B and then I need to turn on what C that's what I need to turn on C then for number three I did not write down number three properly there we go for number three what do I need to turn on a b g a b g and then C and D let me just check it again a b g c and d yeah C and D for number two what do I need to turn on I need to turn on a b g e a b basically G and then an e a b g e and then a finally a d okay for number one what do I need to turn on I think number one is the easiest one I can either turn on BC or Fe I'm just going to go to BC I'm going to choose BC there you go and then finally for number zero what do I need to turn on everything except for G we just write that down everything everything except for except for G okay there we go okay so that's all I need to turn on so let me start turning this on okay so let's go back again to our Domino code our doino ID and now let's start let me just right here number what number nine for number nine what do I need to turn on again I'm going to cop paste this again what I'm going to need to turn on is what the decimal point I can remove the decimal point I don't need to turn it off on I can moove the decimal point okay what do I need to turn on a b g and C and D so I'm going to leave C I'm going to leave D I'm going to leave I'm not going to leave e I'm going to leave b and a that's it that's all I need to turn on except for what G okay there we go so I'm going to remove f and g there we go so this is for what for number nine how about for number eight just write down number eight number eight for number eight what do I need to turn on again paste this first and then I'm going to need to remove decimal point and then I'm going to turn on everything from a to G so I'm not going to touch anything everything's from a to G is already written there we go and then for number seven okay what do I need to turn on for number seven a b and then C okay A B and then C for number seven let me just let me go to my clipboard right here control Z just go here and just say windows and V just go to my clipboard I forgot about this I accidentally just uh I accidentally there you go again copy this again and just turn it off I can paste it there we go so now what I'm going to turn off decimal point and then what do I need turn off everything except for ABC okay so I'm going to turn this off turn this off turn this off and this off so let me just check how code goes until until here let me just check it so let's just try and upload it it's compiling and then it's done uploading what did I do wrong right here doesn't even look like any number right here it doesn't even look like a number looks like a six an inverted nine from my perspective for you guys it most like looks like six which is way wrong so wrong right here h there is a problem now okay so what I need to do right here is what give it a delay I forgot a delay oh so let me just give a variable right here let me say delay time time I'm going to set it to uh second I want it every second so I want it to decrease every second so I'm I'm going to give give it a delay between every number that's what I need to do so let's see how it progress so delay time just give that keep writing delay time for every number delay I'm going to give it a delay of what delay time delay time there we go anded semic call in at the very end put a semicolon and then finally give this to a delay time delay for a delay time delay time there we go delay time and then let's set it up okay now let's see what happens I gave all of them a delay T let's just see what happens again let me just try to go again that seems so wrong doesn't it it seems so wrong what could we have possibly done wrong let me try to again turn on everything first okay so let me just try to go right here and then at the very end I want to do is turn on everything let just try to do that so what did I do wrong here I do not know let's turn this off well what did I do wrong I forgot the curly bracket right here at the very end of our Loop code uh what did I do wrong let me just turn off this one just put it down here what did I do wrong I think everything seems fine so let me just see everything's even coiled up properly so if everything is even what it's even the resistors might be a problem so let me just check the resistors out the problem here let me try to find my there we go finally I'm going to set it to all if it to high so we can actually see it ourselves is it the resistors that are making a problem right here again or are they the are is it or is it our code let me just check I be resistors let me just turn off the light so you can see way better okay when I finally turned it to what all it to high everything seems fine what could we have done wrong then H okay we don't even see nine at first did we see nine first number nine did we see nine properly so we got C D B A and G let me give the delay time even let's give it a more time let me just see 3 seconds every 3 seconds why is that so because I want to see where the error arises okay where the error starts so let me look here even the nine is not correct and then it change the number okay so what could have done wrong here is what what I believe we could have done wrong here is naming it while we're naming the variables so again I made a mistake it happens as I said again but right now I can again check it what relatively that's the best part of it you can check it what relatively so let me go over here and let me bring my diagram again I went through the another mistake again it happens but right here there's a black wire the black is connected to what to pin two what does the black indicate the black indicates what decimal point right yeah the black is the one that's connect the closest one if I'm correct yes the resistor goes here and then it's connected to this one so it's connect the closest one so the Black Goes what to the what to the decimal point am I correct it goes to the what to the decimal point all right it's connect decimal point what did I give it it's pin what it's pin what it's the first pin it's pin what we start from pin three so this should be correct okay this should be correct and then let's go to the white one the white one seems to be connected to the other one let me just again keep checking on the wires just going to keep on doing that okay I see the problem I think I see the problem right here okay no actually I don't everything seems correct oh right oh yeah everything seems to be correct the first is connected to here the second is there the third is there the the silver one the silver is next to the purple which makes sense uh did I get anything wrong let me just put it side by side again just put the side by side okay okay that's all I need to do I'm going to need to set it up side by side and there's pin e and there's pin D H what could be our problem okay set pin e to what set it up by number decimal point and then C and then D and then e and then wait after E I said to e okay there we go I'm correct I set it to e and then I start to the other side what could be the problem right here what could be the problem H so I want this to finally light up as what as a nine so one problem that I did one problem there is let me just show you one problem there is right here is what one problem that there is is that I keep forgetting to do what I keep to give it low right here what happens is look CN D already set to high okay when we're going to number nine c d b are set to high as I said they going to be set to high and then when it comes to number seven and again G set to high too okay wait is G supposed to be set to high it's not I forgot about G right here let me fix G up so we fix G up and then C okay all of it are set to high Okay C DB a are set to high and then what happens here is what you only want a to G set to be set to high no problem okay everything what is set to high that makes sense but the problem starts here what is the problem right here can you see the problem C and then B and then a can you see it c b are the only ones that are supposed to be set to high but we already set everything up to high can you see it we set everything to what to high this is where the problem starts okay so we set everything already up to high and then we only want to set this to what to high so we have to what technically what do we have to do we have to turn everything low before what moving into the next one because right here I set everything from a to G to what to high already and then when I go right here from c b and a I only want them to be set to high other ones they're going to be set to what to low what I want right here is what what happens what quite the opposite okay so what happens is quite the opposite so everything's already set to high and when I try to set this high again it doesn't make any difference that's what's happened okay so I need to do is what I need to go over to my code right here again hopefully I have everything intact let me just get this right hey this oh let me go to my clipboard again there we go got everything right instead of removing them what I'm going to be doing is what I'm going to be setting them to what to low okay the ones that I don't want I'm going to be setting them to what to low a b g c d so we need c we need D we need what we need what we need e we don't need e so what do I do I set it to low okay because it's going to affect the next number that we're going to what we're going to be touch it so we're going to set this again to high or low we cannot just remove it okay so this was already set to high okay a is supposed to be set to high we're not going to be using F so we're going to be setting it to low and then how about G Okay g is supposed to be set to high too all right so we're not going to touch it so let's try to upload it right now let's even see if you can even see nine as a as a number so let's just try to open it you cannot see what okay you see that for the first for the first seconds what happens is what you don't see the whole thing light up we see 1 2 3 four four LED segments light up how many LED segments should be lighting up 1 2 3 four five let me just check my code again five segments should be set to high 1 2 3 4 and five what could be the problem I generally don't know what the problem is so I think what I'm going to do right here is inste uh wasting wasting time is I'm going to try to figure the problem out myself and then I'm going to come back here and try to solve it okay so I was about to rerecord the whole section but uh I made what what I made was a very very simple I made two very simple mistakes the first one being is that the resistors right here are touching so let me just move my move it right here and these two resistors were touching each other all right so basically what happened was when these two resistors touch each other they started to what they started basically to fuse as if they were just acting as a one resistor so basically it was not working on its own okay these two resistors that was the problem that I just made so there's a good chance that the the code is working for you um so right here that's the first mistake right here okay and the second mistake here is when we're using nine okay we need to also turn on F okay we also need to turn on what F all right that's just one thing you have to keep in mind let me just show you guys where f is there we go we need to turn on F which is supposed to be around here okay so with that in mind what I should be doing right here is what set this to high that's our first mistake solved it I untangled the the resistor right here I untangled it myself okay so it should be working properly right now I just separated them and one thing we need to finally do is what we need to finally write down the whole code of this obviously I not do that for this one let me just do that me go here here let me just copy actually number eight because all of it is set to high it's going to be easy we need to copy the whole thing not just part by part let just do that copy that just paste it here wait I oh I I took it off I deleted number eight let me just leave it there copy that and then I'm going to paste it here just going to supposed to remove number seven here all right there we go this should be paste there we go number seven paste let me just give a space right here just you can again have more space there we go now what I need to do is uh right here is what what is supposed to be set to high ABC so other than ABC everything is supposed to be set to low just keep on doing that let me turn on cap lock and there we go low EC supposed to be set to high so I'm going to leave this one and this one to low and then finally G to low so now let's just check and upload it okay should be compiling and it's working perfectly fine now okay and it's working perfectly fine it counts to seven that's good it goes back to 9 87 let me just change your angle so you guys can actually see it from the right spot let me just do that there we go let me just put it right here there we go let me turn off homeone light so you can see it way better now you can see it from a good Angle now it's going 9 8 7 okay the delay time is Big so let me just change it to it set to uh let me just check it 3,000 millisecs basically 3 seconds I'm going to set it to what 1,000 milliseconds basically what a second okay so what we're going to do right now is write down the whole number so let me just write down we're on number what number six number six what do we need to do for number six again I'm just going to paste this code right here for number six afg e CD need to be turned on so basically B needs to be turned off what else um yeah basically B needs to be turned off that's I think all that is supposed to be turned off there we go so B needs to be what turned off so B set to low for number six all right now once we're done with that just going to set this up to what number number five paste the code again so for this case one needs to be turned off B and then e b and e needs to be turned off low and then for E2 it's going to go low let me just check it again AB okay A a okay B is going to be turned off because it's not here then there's C there's d e needs to be turned off and then F and then there's G so I'm not going to touch that so let's just check it out right now actually let upload it right till that time let me just write down number four okay it's going 7 6 5 okay okay let's write down there we go okay it went to number five now let's write down number four that's all we need to do let me write down number four all right go to digal oh I just need to do is paste the code again one needs to be turned off right now and needs to be turned off let me just turn off a first turn off a no I need to turn on cap stock there we go turn a off how about b b needs to be turned on C needs to be turned on D needs to be turned off let's go to D and turn it off okay how about e in this case e needs to be turned off too let's go to E how about f f needs to be turned on and then G needs to be turned on so I'm going to leave it like that okay and then again keep on doing this for number three paste that and what need to be turned on for a C okay a b g and C D okay so basically e needs to be turned off okay D is turned on E and F needs to be turned off so let's go to E and F and turn them off low and F to low okay afterwards let me go to number two number two paste that for number two what needs to be turned off C and then what uh D needs to be turned on so e then F okay so basically what what C and F needs to be turned off so let's go to C and F and turn them off let me turn them to what to low okay F needs to be turned low again for those of you are using a cathod pin you're going to be exactly doing what the opposite of what I'm doing if you want to turn off something obviously what you're going to do is what you're going to set it to high when you want to turn off something when you want to turn on something you set it to what to I think you guys know that all right let me just keep that in mind and let's move to number one number one let's number two right here number one paste that and what do I need to do for number one only B and C need to be turned on so most of it is going to be S to low okay B and C need to be turned on just go here how about e low B and C I'm going to leave B GNA go to a turn that low and f and g what is left only Zero's left so let me write down number zero number zero and paste that what needs to be turned off for number zero everything is on except for what except for G so only G is going to be what set to low one final thing I want to do on number zero is I want to add uh I want to add the decimal point because we've not been using it so I want to add the decimal points and what I'm going to do is say decimal point and set it to what to high okay so if I'm send setting this to high what do I need to do as soon as this is set to high after it goes to one round it's got to kept it high because I've never mentioned decimal point here so what do I need to go do I think I wrote it down myself but what you need to do is what you need to set it to low okay you need to set what the decimal point to low I just do don't do that right here and let me just upload it just removed it for now let's see what happens okay so 9 8 7 6 5 4 3 2 1 zero okay the decimal point you see that the decimal point after another round once I set it to high again on number zero when it when it reaches number zero I set the decimal point to high it's going to what continue on being high as long as I don't write the code to what to keep it on low so I have to write down the code to keep it on low I cannot just what neglect it okay so let me just do that and let's upload it right now okay nine 8 7 6 5 4 3 2 1 zero the decimal point and then decimal point turns off there we go now we created our own timer okay so this is as far as we go on the LED I think we're done with this one so um see you in the next section okay so in this section we're going to discuss about 4digit seven segment LED displays so far we've worked with u normal s segment LED display but now we're going to work with one that has a four digits okay so one thing that you notice right here that is off the bit is when you look at the four digit 7 segment LED display is that it only has as you can see right here it has six pins right here it has six pins so totally it has only 12 pins okay when you look at here when we think of seven segments again how many pits do we have for each segment right here we had almost what we have eight segments so we have eight again eight pins for segments and then we have two pins for the common as you can see right here we have five pins and five pins so totally we have 10 pins so how much pins do we expect right here we expected at least we expected how many pins we had eight pins again eight segments here so we're going to be expecting how many pins we're going to be expecting 8 * 4 which is going to be 32 and then we expected two common pins which is going to add it up to a total of what 34 but obviously our Arduino only has how many digal pins let me just unplug my Arduino so you can see it closely if you look at my adino Nano right here it has around 13 dis pins it goes to digital pin number 12 right here and then there's digital pin number 13 at the very edge can you see that even let's say we're trying to use our analog pins we only have how many pins we only have seven analog pins here okay so right here even if you add it up we're not going to have anal space for 34 P so right here they use a very very simple yet a very genius way of of us of making it of Designing it in such a way that um it only needs 12 pins basically two more than just our normal basically two more than just our normal seven segment LED display so let's see how this works okay let me just plug my again seven segment LED display it's very familiar to the elite display we have here okay the four-digit one is very very familiar to this one let me put it actually in the other side so it can actually be better there we go the focus isn't good wait let me fix up the focus let me get around here there we go now it's better so now the question is what are these what are these pins again what are these pins what do they represent so let me go over to my screen right now so you can see it for yourselves and when you look right here there is what there is D4 AF F D3 D2 b e d DP c g and D1 so one thing that again you're familiar with is are those a to G Pin so you're familiar with the segments a f b e d DP C and G but you're not familiar with these ones that are marked with the green the D1 the D2 the D3 and the D4 so D1 D2 D3 D4 basically means is right I want you to keep this in mind is D1 represents digit one D2 represents digit 2 and obviously digit D3 represents digit 3 and D4 represents digit 4 okay so the question is what are these these are I want you to think of them this deepens again this digit pins I want you to think of them is as the common pins okay I want you to think of them as what as the common pins okay so again right here uh if it's a common anode and common Capote they exist here too we obviously had a common anode and common gape when it came to the what when it came to seven segment L display they are also exist here too so they they can be a common anode when it comes to four-digit one they can be common anode or common cathode okay so when it comes to D again depends they act as a what as a common pin so what you want to turn on something what basically happens is what let's say we want to turn on a on digit four if you want to turn on a on digit four what do we do is we do what we turn a for example let's say I'm using a common cathode for now I'm using a common cathode my pin is a common cathode okay my four digit U LED segment display is common Capal so I'm going to be using common Capal as an example so what should I do right here a needs to be turned on to what a needs to be turned on to high okay the pin that is connected to it's going to be turned to high and then D4 is going to be what connected to the what it's going to be connected to low basically acting as a what as a ground basically it's going to act as a 5 volt and then there's a resistor right here on the segment as as every time we did um using the seven segment LED display the on digigit seven segment LED display what we did was what we always connected the resistors to the what to the segment we're still going to carry this roomle okay so we're going to be connecting the resistor to the Ain and then what we going to do is what we're going to turn on again we're going to use the D4 as a what as a gnd d as a gnd d Comon bin and what happens is what we're going to turn on a where is a supposed to be let me just Google the seven segment LED display there's an image of where a should be okay there we go the a is right here the a is right here at the top so basically we're going to turn on this part this part that is what we're going to turn on this segment it's going to be at the digit four and what it's going to be a okay so let's try to first things first let's try to understand you know how to connect these things okay so let me just try to exactly do what I did right here okay so right here mine is a bit different again with the number okay you always going to check the number right here let me just unplug it for now you're always going to check the number and then search for the data sheet okay you're going to search the number right here you're going to write the number and then say LED Matrix and then what and then search the data sheet again to just see this layout of how yours is going to be because it's going to be different from again from U uh the display to another so from kit to kit it's going to be different so again always keep that in mind okay so right here I already made myself a documentation right here okay I'm going to show you guys how to actually make it if you guys do not find the data sheet on online sometimes there might be cases where you don't find the data sheet online I try to Google mine I put my number right here I put my number right here and Googled for it and then I could not find it so what I basically had to do was write a documentation a data sheet myself so I'm going to show you how it's done but for now let's try to again focus on how uh these again four segment LED displays work okay so right here let me just get it as close as possible to the we know just put it right here okay so let me bring two bring one resistor here let's bring a resistor let's bring another wire right here mine is a common cathode so what is the common pin right here the common pin for me is what the common pin is going to be those D pins let's say I want to light up digital pin number one here I want to light up this little pin number one okay what do I do I go to the very edge again I kind of forgot to put the dot here I only put 888 here let me put the Dots here forgot the decimal point there we go fixed it up right now okay so what do I do I literally put right here this is going to turn on digital pin one as you can see sorry I said uh it's going to turn on the digit number one the first digit basically and I want to turn on a this one so let me just go right here but before connecting to a segment what do I do I always use my resistor let me just get my resistor right here a 1,000 Ohm resistor we're going to be using the same resistance when we were using in u the seven segment and the Seven segment LED displays basically this ones that have one digit okay so let me just do that just try to turn on a this should be easy okay there we go moved it across let me just bring it closer so you can see it I again I connected this one right here oh I think I jumped one oh jumped one actually I'm not correct there we go now it should be at a as you can see I connected it to a all right everything seems to be working nice now and then I connect this one to the red so obviously what do I connect this one to I'm going to be connecting this one to what to the 5vt while I'm going to be connecting my common pin because it's a cathode again it's a cathode since it's a common cathode what am I going to be connecting it to I'm going to be connecting it to g& D let me just do that okay seems to be have been connected let me just push it in just need to push it in a bit and now let's try to light up ouro with that let's see what happens here okay let me just touch my resistors I'm not sure if the resistors is causing the problem right here it's not lighting up let me just try to push it the whole way in it's nothing is lighting up right now going through an error let's just see what happened right here again let me just check my pins let unplug my adrenal first let's check our pins we been connected the 5 volt all right I connect the 5 volt to this one all right nice the gnd D I connected the G and D to this one which is good let me just make sure this is what digit one as you can see right here this is digit one let me just check if I connected it to the first digit yes that makes sense I connected to what to a gnd d can you see it I connected it to gnd D and then afterwards what did I do and then okay connected the resistor right here to an a connected the resistor right here to what to an a the a pin so basically what should have been lighting up this one should be lighting up this segment should be lighting up this one right here should be lighting up okay so everything I think should be working fine oh there we go everything is fine now it's lighting up let me just turn off one light so we can see it better okay lower the light a bit let me give it a different color right here there we go and now I think you can see it way better I'm just trying to focus at it there we go now it's lighting up okay so we just did that but right now the big problem again being here is okay I turn this one on let's say I want to turn on digit number two I want to work with digit number two now I just wanted this to be on and I want to work with digit number two okay digit number two is what again is I'm using what a common code it's going to be connected to the gnd D all right where's the digit number two right here digit number two is after a I'm going to have to jump okay a step and F and then go to D2 let me just do that so all I need to do is what go to D2 right here what else I should do is what I should be connecting it to what to resistor or not I shouldn't be why is that so I'm working with a what with a common pin when it when it comes to Common pins we don't connect it to resistors but when it comes to individual segments we connected to what we connected to again resistors so okay let me just Skip One and go right here just did that can you see it let me just focus here there we go skipped it and now where do I go I go through the gnd D basically I'm going to share this gnd D with this okay there we go this as soon as I do that can you see that just try to there we go get my resistor can you see it one thing you notice is okay seems to be working fine now let let me just try to connect the you know I want to turn on F2 I just want to turn on F okay there's a problem that's occurring but let's just again go and let's connect it to F right now and then we're going to talk about the problem of doing this let me just connect it to an F right now okay how do I connect it to an F I'm going to need again a resistor right now because I'm lighting up what an individual segment all right so I'm going to what I'm going to need to connect it to an F so where is it it's around the middle have to go between these two yep it's just going to be a bit of a hard one it's going to be a bit of a hardship to do actually all right there we go connected it to an f and then I'm going to need a wire I'm going to need a long wire actually this time I'm going to get the white wire it's very long there we go what am I going to be connecting it to to 5vt because I'm using a common cathode again the individual segments will be connected to what they'll be connected to the 5 Vol let me just do that they should be connected to the 5vt just the resistors let me just check both the resist SS all right there we go just touch the resistance right here can you see a problem with carrying it's not consistent as you can see it it's not really consistent what is the problem here the first problem is okay the first problem being let just take off this one just take it off for now so you can see it the first problem was there's not what there's not enough power to turn off to turn on all these displays okay that is the first problem okay so as I said again these again when we were when we were putting our resistors they were intended to what they were intended to for what for one segment LED displays they were intended for one segment what led displays so basically we turned on at maximum we turned on eight segments here remember maximum we turned on eight segments just think of them lighting up what eight LEDs here but right now we have how many segments we have around eight right here 88 8 basically we have 32 segments how are we going to light up 32 segments because it's going to require a lot of power it's going to require More Voltage than 5 volt okay so one thing we could have seen right here is when I put the fpin right here when I connected try to connect the fpin everything what everything blacked out what happened basically was it did not have enough power to light up all of them okay did not have enough power to light up what all of these segments again okay that's one thing just want you to keep in mind they had no enough power to what to light up again two again two different digits okay so right now another problem is it starts copying the same thing can you see it if I just put right here a right here it's going to light up both let's say I want to turn on one let's say I want to turn on I want to represent the digit one two the problem here is what okay I need to turn on this and this for number one and I'm going to need to turn on another type of what another type of segments for number two but right here what happens is what it's copies the same segment so when I light it up in this manner what happens is what it lights up what it it copies the same thing it copies the same thing so which is going to be what it's going to be very very horrible you don't want it to be exactly the same I said again let's say I want to turn on one right here and once I want to turn on two they going to be a problem right here let's say turn on two okay I'm just going to add up these segments right here just fine but when I want to turn on one what happens is what I have to turn off this one okay I have to turn off this one so basically what happen happens is what if I turn off this one it's going to turn off from this one too so they start what copying each other which is going to be bad okay so this is where the problem arises okay this is problem number one the problem number one being what it copies the same thing and the second thing you can see is if you focus again is the what the division of power is not very very consistent look at it let me just turn off the light can you see it one is very very bright right here and this one is very di now just thinking just think of trying to light up 32 different segments here which is going to be what almost impossible it just even tapped out when we tried to connect it to an F as you could as you could have seen in the when I tried to connect to F right here the F pin what happened it just tapped out it couldn't do it basically all of it turned off okay so this is the second problem that we have here okay so how are we supposed to light it up then well one thing that you need to keep in mind is where are always supposed to light up just actually take off all of this we're supposed to light up what we're supposed to light up only one digit at a time so we only can light up one digit at a time so right here if you look let me go again to the image right here if you go to the image right here what you can see is what a FB all these segments are what they're common to what they're common to the dpin the dpin are the one that are specific right here we have D1 we have D2 We have D3 we have D4 they're specific while a FB again e d decimal point C and G those segments right here they're what they're common they're common to all of them okay so one thing you can do is what we can light up everything here from a all the segments but we can do it what we're limited to what we're limited to what we're limited to one digit at a time okay we're limited to what to one digit at a time so right here when we do that again when we just think of again using the on digigit LED matrix it's going to work perfectly fine when we use using one digit I just want you to think of them as what is like four again these four what these four one segment LED displays connected together okay systematically so that they have 12 pins so I just want you to think of them is what is four again four one digigit seven segment LED displays okay so right here again there was specific if we had specific you know specific uh U excuse me we had specific segments for all of them it would be like A1 there will be A1 it'll have a different pin for A1 we're going to have A2 we're going to have A3 we're going to have A4 so basically we're going to have a lot of pits obviously we cannot work with all these pits so another problem arises while using this method through the problem is okay I want you to keep this in mind the problem is okay one digit at a time okay one digit at a time okay it works perfectly fine when we use one digit at a time let me just again let me again to prove this again let me just connect uh let me just connect three pins using the let's use digit number again digit three right here let's try to connect again just three or four uh segments right here let me just do that so you guys can understand it all right let me just unplug this where's my digit number three right here digit number three is here me just focus here digit number three is here so it's going to be the one at the very edge the one close next to the very edge there we go just push let me first push this one so that it doesn't move a lot there we go but it's still visible there we go it's a I'm lighting up what a digit so I don't need to use my resistor I'm just going to connect the directly to what I'm using a common cathode as I said again so I'm going to be connecting it to gnd D the D pins are going to be connected to to the gnd D I just want you to think of the digital pins the D pins the sorry the the digit pins as what I just want you to think of them as common pins again they're marked with what they're marked with the number of their respective digit that light that they light up okay there we go connected it to what supposed to connect to gnd D there we go connected it to the gnd right now let me just focus here so you can see it way better there we go and now what do I need to do let me just light up again one segment right here I don't care that much so okay I'm just going to light up B because it's close to uh it's very close to uh the digit number three all right there we go now I'm just going to need my wire let me just wire this up let get my wire right here then I'm going to be connecting it to the 5vt I've got my resistance all right my resistance is check does it light up B I think it lights up B There we go let me just try to light up another one too just for the sake of it let me bring another resistor let me just light up someone that that somewhere that is here just go right here can you see it hopefully you can there we go we go should be around here I'm going to connect this to 5 volt let me just light up to why I think two proves the point so I don't need to light up more than two there we go okay I need to push in that resistor I'm just push in this display and the resistor can you see it let me again turn off the light when we again use one digit at a time what happens is what can you see it it lights up properly there's no what there's no div when you see the power division of power right there was uneven right here it's even okay as you see it right here it's even and then two I don't need to copy it's not copying the same thing but it rises again another problem the problem with this method is using one digit at a time because it's intended to do it's because it's intended to be used at what as as one digit at a time so what happens here is the problem most people I think think about right now another problem is what if we use one digit at a time it destroys the purpose of what it Ro the purpose of having a 4digit LED display because right here let's say we want to turn on you know 1 2 3 4 right here I just start the resistor okay let's say we want to turn on 1 two 3 and four right here we want to turn on 1 2 3 4 we can do that if you're using what one digit one digit um for only using one digit at a time basically what happens is what what basically happens is what we cannot turn on all of them at once well one thing I want you guys to keep in mind is okay um one thing I want you to keep in mind is always is that these things are very very fast I'm talking about these LEDs are microcontrollers computers are very very fast okay so let's say we want to turn on one what do we go we go to digital pin one and then we turn on again two segments we're going to turn on these two segments okay we want to turn on let's say one okay we want to turn on that and let's say we go to digal again we're going to go to digital 2 we're going to turn this off after we're done with it we're going to turn it off and there's still pin two we're going to to D two connect D2 right here and then we're going to light up all these segments again the one that marks a two we're going to go right here and light up all these segments right so you might think that it's going to go really slow we're going to see one right here and then we're going to see two but it's going to happen very very fast okay I'm talking in milliseconds it's going to happen very very fast in milliseconds that we're not going to notice one turning off okay we're not going to notice one turning off and then switching to two one turning off right here and then and are you know going here and lighting up two it's going to happen so fast that we're going to what we're going to keep seeing one and then we're also going to keep what seeing to right here okay for our eyes it's not what it's not visible for us so that's one thing I want you guys to keep in mind we're going to be lighting up one digit at a time but it's going to happen very very fast that our eyes cannot what our eyes cannot notice it okay our eyes cannot notice it so that what so that we can basically what turn on all of this at once so we can turn on all of this at once so technically speaking we're not turning all of these at ones we're turning this on we're turning this off once we're done with this we go to this one and then once we're done with this we go this one once we're done with this we go with this one but it happens very very very fast that our eyes cannot notice what this turning off okay these turning off okay the the others turning off it's going to happen very fast that all of them for us it's going to appear that all of them are what all of them are on and they're what they're displaying what they're displaying numbers okay that's one thing I want you guys to keep in mind okay so right here one final thing before uh moving on is again the problem here is what let me just turn on our lights the problem I encountered myself was okay the problem I encountered myself was I could not find the documentation on my specified type of what on my specified type of four four-digit uh seven segment LED displays okay I could not find a specific data sheet okay if you look at the image right now when you look at the image it's very very different from my what it's very very different from the one that I had here almost everything's the same when it comes to segments right here a f b e d DP C and G are the same but the but the layout of the what the digits is very different digit one right here is located at the very very left per me left top while digit four the well in the image it's digit four so again how do we find you know which digit is which and how do we label them and write this down for ourselves because sometimes you might I find what if you have a less popular uh less popular type of code right here you're not going to find what you're not going to find your LED display D sheet there's a lower chance of it because I do not find it myself I've been looking around for like a good 20 minutes 30 minutes but I could not find any data sheet on my specified type of um four uh digit um semi segment LED displays so right here what I did is first things first I wanted to know if it's a common anode or a common cathode okay how do I know that let me just Again Begin from just turn all of this off okay let me just do that how do I know that that how do I know that okay how do I know that what I did is what okay I just assumed that's what this is going to be the digit PIN right here let me just assume this is the digit PIN okay again assume this is what this is going to be a digit PIN I just started with this and I started connecting it to it I just assumed again you're going to you're going to be doing it with trial and error okay you're going to be using a method of what trial and ER until we get one segment okay so right here let me just again use this as a what as a digital pen right here I'm going to be using it as a dpen as a what I'm just going to assume this a common cathode so if this is a dpen what is it going to be it's going to be connected to gnd D connect to gnd D all right I'm going to assume the other one the next that is right there as a segment again so you're going to keep on trying until again you find the right one until you find one uh one segment lights up okay let me just again assume this is a common let meum assume this is a common actually you know what this is a common code but let me just assume this is a common anode for now so to make things very easier for other people who have a common anode so let me just show them right here I'm going to be connecting this to the what if it's a common anode I'm going to be connecting 5 Vol let me just do that and let me bring another pin again I have my resister I'm just assuming this is what this is a segment next to it it's a segment I'm just assuming that again this is assumption until we find until we basically what until we find when it's right always one thing you have to always keep in mind is what we always have to light up again or what we always have to use resistors because if we try to connect one without any resistor what's going to happen is when we're trying to find out which one's which we're going to basically what fry our LEDs our segments right here we don't want to do that again okay so just keep that in mind okay it doesn't turn on Okay what I'm going to do is I'm going to be moving I'm going to start moving okay I'm going to be starting to move my resistor to the other pins I'm not going to change the commment pin again I'm just going to keep it like that for now I'm just assuming this is a dpin okay I'm just going to keep doing it let me go with the other one right here let me Focus actually here there we go I'm just going to keep doing it it's not lighting up again pushed it let me just push it again just push it so they can even see it there we go it's not lighting up I'm just going to keep on moving the resistor again one one at a time to the next spin try to connect to the other one it's not lighting up okay let me try the other one let me try a whole row before actually concluding okay so let me try at least one of these six spins before actually concluding so okay let me just try to connect this one to the resistor is supposed to be here okay it's not lighting up so what could I possibly say right here either I did not connect it to a right digital pin right here so okay I do not know if I connected it to what to a normal dpin I'm just going to assume again a segment again just going to keep doing this until we find what correct answer so let me just keep touching this again changing it keep changing it okay I reached the resistor point so I'm not going to touch that again there is a probability of finding it let me go to the other side right now now we have to find again one of those digital pins are supposed to be here one of them is supposed to be what digital pins right here just keep doing it keep doing it it's not lighting up nothing is lighting up right here keep doing it all I reached my end of this side so basically what could happen is what I reversed it basically it's so what it could be a common what common cathode instead of what a common anode right here I tried it as a what as a common anode okay it's not a common what it's not a common anode so let me try a common cathode so let me just reverse it so right here what do I need to do is again set the the deepend are supposed to be set to what they're supposed to be set to G and D let me just do that again this I'm going to be assuming this is what going to be assuming let me start actually from right here keep on let me just start from here because I know this is the the deepen I don't want to start from here I just want to show you guys how we do it right now since I already wrote it down again I wrote down the documentation all right let me again go here right here let me just again put a segment right here and let me connect it to a what to the 5vt segment to the 5vt segment to the 5vt okay let me again push it push it a bit in so we can see it there we go nothing is like lighting up okay maybe I have to move this again here let's see if it lights up where's the 5V did I get the gnd D right I think I got the g&d right wait right there we go oh I did not even connect this one to the proper resistor I'm supposed to connect the same the same R there we go can you see it oh now it's lighting up if I put it right here it doesn't light up but if I just put it here it lights up okay let's say to not find this one again let me just go over right here and let's try to find it again let me just try to find let me just try to what my objective here is to at least try to find what try to light up one segment that's that's my only objective here as soon as I do that it's going to be easy what did I do wrong here let's keep on pushing it again I'm just going to make sure the resistance is again intact oo now it's lighting up so let me say okay this this light up let me just say Okay this lit up so how do I extract the information right here okay this one that is right here okay there's something right here I'm just going to again check it it's the one at the very very left okay I'm just going to draw this diagram right here before lab labeling it okay let's just say I'm labeling it right now okay let me just hide this for now let just hide this for now there we go let me just draw this diagram again that looks like this and shows the pins so right here it's lighing up at what it's lighing up at the the what at the fourth digit so what does this mean this is the one at the very very again at the very very right so this one is supposed to be what this is supposed to be digital what sorry I said digital I meant digit number what it's going to be digit number four it's the fourth digit okay it's digit four all right so this is what this is going to be D4 that is right here it's going to be what I hooked it up to here it's D4 what other information can we also extract it's a common anode or a common cathode it's a common cathode because why the D pins are what they're connected to what to the G and D okay so they're what they're basically what they're basically uh common what common cathodes okay we extracted this information what else can we extract here can you see the segment right here let me go over to my image right here to my screen and when you look right here a is at the very top so what does this mean the segment we connected right here okay the segment we connected right here is what the segment we connected right here is what it's going to be what it's a so this is what if if you let's say go here let me just go over here there we go the one that we connected right here is a when you look at the resistance right here the leg of the resistance is touching a can you see it it's touching a there we go a oh I just moved the resistance again that's the resistance that uh oh there we go I moved the resistance there we go a so I also discovered a pin right here just little pin let me just go over to it h so around here I think so it's around here there we go now what is this this is what now we can just again look where it's located right here what will we connected right here and then we can say what is this again let me just move this to the top can you see it it's the one at the very very what at the very edge what is this then it's appearing on digit one so basically it's what it's D1 right here when it comes to White one again the white um wire it's going to be connected to what to D1 okay what is this again a so we can keep finding them again by doing what by lighting up other segments that's all you need to do so let's say we're trying to find another segment what do we do right here we're going to move our resistance right here and what does when it does not light up what does it mean when it does not light up it's it's probably what it's probably a what a dpen so we're not going to touch that so we're going to leave it again we're going to light up all the segments so basically let's just trial and error until you find one segment as soon as you find as as soon as one segment lights up you can extract lots of information from here I can extract what this is a okay this is a from here from the red wire I can say this the pin right here is a what else is it it's on the first digit so it's what so it's going to be what the digit number one is going to be here what else can I extract right here I can say it's a common anode or a common cathode so again you keep doing that and find all the pins okay and name all of them that's all you need to do so with that in mind we're going to actually work on a project in the next section and we're actually going to wire up all of this which is going to be a lot of it so we're going to wire up 12 so anyways we're going to see you um see you in the next section we're actually going to work on a project with this one okay so we're going to build as a timer okay just like how we did using the one segment LED display right here one seven segment LED display with the one that has one digit just like how we did that we're going to be building a timer and it's also going to be including a buzzer okay it's going to have a buzzer right here an active buzzer and it's going to actually ring after what the timer hits zero okay so just to save you guys time I did all the wiring up that was necessary again so I did every wiring up and Drew down all of the all of them as variables so let me just again get this closer so you can have a good look at it and what which where where it's going so let me just just make a simple again let me just explain it simply these are a andf the let me just again bring this closer how am I supposed to do that let me it's actually hard let me just bring the camera down this time it makes more sense to do that there we go let just bring it way closer here all right so these two as you can see the black and the silver again when you look at them they're connected to what to a and F they're connected to resistors right here one resistor leading to a and the second resistor leading to what leading to F okay that's all I did then afterwards what I did was okay what I did was I put this again as you can see it right here can you see this the silver one the silver one is supposed to be D1 okay it's D1 and afterwards these two colors right here the purple and the blue respectively are D2 and D3 and finally I set a resistor for again B because it's a segment again and then use the going color okay then afterwards what I did was okay I went to the other side because I did not have space in this side too as you can see I don't have space on this side so I just used another small breadboard just to go through it just like how I did using the 1digit 7even segment LED display so what I did was again connect again these pins again these pins in order right here we start from yellow again the next color is yellow as you can see on the stripe and then connected them respectively so yellow represent res e then orange represents D obviously then red represents DP and then the brown represents C and then right here because I run out of wires right here again uh we're connecting lots of pins because I run out of wires what I did was I used a single white wire right here specifically a single what white wire right here as you can see it and this is connected to it is connected to G okay and one final thing is obviously we have D4 right here that not use let me go back right here obviously I don't have to put a resistor on this so I put it right here and connected it to what pin 13 okay can you see pin 13 is the very very other side let me just again just give this let me change the color a better change it to there we go I think this is better there we go D13 all right D13 is right here then there's stillin with 13 again you can see it from another angle there we go there's still inin 13 so that's what I did I connected them and separately I run out of digital pins right here okay so one thing I want you to keep in mind let me just put this in its normal angle okay there we go so one thing I did right here as what after I was done with setting up the four LED again four-digit LED Matrix uh LED U segments right here what I did was what I set up a different circuit a big black one I used an analog pin because I ran out of a digital pin right here I used an analog pin okay I used what I used an analog pin and then I used a diode okay a diode again as I said supposed to change what supposed to change AC circuit to DC circuit all right and then I used my active buzzer active buzzer as I always told you guys it it what it needs five volt DC it receives what 5V DC direct current and basically what again what does uh let me just explain the science before we go behind it uh what does a diode do it basically can convert AC to DC let me just show you how it does let me just bring the paper right here let's go over the signs before you know we keep walking and focus on the again this the four-digit uh the 4G dis four-digit display because it's going to be the main one right here it's the main component here basically when we use a diode if you remember remember AC circuit goes both sides it goes both sides okay when it comes to DC circuit it only goes what one way okay it's straight it goes one way when it comes to a diode if you remember I told you guys even when we using these LEDs let me just bring an LED right here I think an LED would be a great example because they're diodes too they're literally what light emitting diodes they're diodes but they what they emit light that's their like special property but they're just dios they're the same thing okay so when it came towards um these again diodes they were represent like this if you remember and then we again presented them in the circuit so this is what the positive side and this was what the negative side okay is it the positive and the negative I think I actually switched it up there we go it's this side it's positive and negative here anyways the main thing here is what the main thing here is if we connect it to the positive again we connect the positive to the 5vt and the negative to the g& D it worked but if we switch the the direction what happened it did not work so basically what happens in diodes in diodes currents only flow in what currents only flow in One Direction as I told you guys currents only flow in what in Only One Direction so that's basically what is it's doing when we receive again inputs from analog pins and digital pins they're always what as I said again they're always AC so to just change it to 5vt DC what does a diode do diode only receives what half of what the AC is sending it's going to be receiving half of it so basically it's going in both directions it's going to receive only the One Direction and it's going to what it's not going to receive the other one it's going to be dull and then keep on doing this so basically over time it looks something like this if we just again Lower it down let's just say we tune it down it's going to be almost as if we're getting what we're getting DC circuit okay just as if we're getting DC circuit that's one thing I want you guys to keep in mind okay when we working with this a diode let me just show you guys what a diode looks like this is called a rectifier diode again read your labels and try to find some sort of diode okay this is a rectifier diode right here okay basically does what changes what it's used for what basically to change AC circuit to what to DC circuit okay again the side again you have to understand the side okay how you set it up is again important because s if I just again change the direction right here and put it like this if I put the there we go if I put the again silver mark right here with the with the positive sign okay with the positive sign what's going to happen is what it's going to basically what it's not going to connect it's basically going to be silent but if I was to change the direction right now I change the direction it's supposed to be like this if I change the direction like this it's going to work perfectly fine okay just keep that in mind let me just put it back to its spot though don't want to ruin ruin it oh I think I bended it a bit I don't think it's in the positive side of the okay there we go the positive is here all right there we go connected it obviously if I don't hear anything I just set it up wrong again we can know from just again listening to it if you don't receive anything then basically what I did is what what I did is change the direction okay let me get this out of the way and the gnd D if you can see right here the gnd D let me just make sure you can see it the gnd D is again extended by this it goes the whole way here and then what happens goes what to this side and then it goes to the other side of the what the active buzzer okay so now let's focus back on the again four segment LED display so everything before obviously we start what you want to do is what we want to check if everything's hooked up properly especially the resistors again there might be cases where again the resistors are not connected properly basically we have to push them in so let's just see if if they're connected properly so let me go over here to my code let me just do that I have another code I want not this one I think it's this one no it's definitely not this one how about this one I think it's this one there we go okay let me just remove this code I don't need this I'm gonna go back to this we're going to be including Library so we're going to get back to this but we want to do is check everything so again I just set up the pins again gave them the name and then connected them to their what to their again the pins that um we had to use again to the respective pins uh one thing you notice here is I again recommend that you don't use digital pin one and pin two because again they're used for what for binary but this time I was using digital pin one why is that so because I don't have any space as you can see I did not have any space I finished what until 13 I used every pin until 13 I only have up to 13 and I used every digital pin that I had okay so that's why I used two again you can use them but most case when you don't need to don't use them okay so again we're going to start here and then again I set up everything D1 D2 D3 D4 and then I set up a delay time set it to 100 milliseconds we're going to get to it and then obviously I have to set everything to what to an output just like how we did in the for in the on digigit uh seven segment LED display just did the exactly same thing and I set every segment to high so we can see it including the decimal point and then obviously what do we do we're going to again using a common cathode so in this case we want the g& d so the one we want to light up right now we're going to set it to what as a g&d we're going to set it to low so we want we want it to act like a g& d so we're going to set this to what to low basically to have what to make a complete circuit soon as we turn this all of it to high and then we turn this to low we basically me what we create a 5 volt to ground type of circuit a a complete circuit okay now I'm going to set every other to what to high let's see if I don't set this to high let's see what happens if I don't set this to high let me just comment this out let's comment actually the second digit too let's let's comment everything and let's just focus on this one let me just do that let me just comment everything and focus on the first one okay and I'm going to get back to them comment it out commented out now only this one should be working then I say what I said this below but let's just say I forgot about writing these again I just only focused on D1 right here and forgot about these let's see what happens okay should be done compiling and now should be uploading can you see it one all of them are lighting up as you can see but obviously there's a problem right now the problem is it's not consistent I mean let me just turn off the light so you can see it way better some of them again what light up bright and the other ones are just Dim when you look at them other ones are just dim I don't think you might notice it in the camera but when you look at it in real life it's just the for example the four digigit right here is very very dim okay and obviously they represent what the same character over and over again right now I just wrote down eight uh I wanted to write down eight and they represent the same character I want it to have this this is not lighting up okay this is not lighting up I have to think it's this one there we go let me add that segment the G which which one's not lighting up right now right now the middle is not lighting up let's just see what even segment here is the segment is G what pin is it uh pin 12 G is attached to pin 12 where is G G's here okay G's right here so should be around here okay there we go it's a bit of hustle to to even connect them there's a lot of pain even in connecting these okay there we go now now everything's lighting up but as you can see everything lights up so obviously what should we do right here should set everything what everything by default is what everything by default is set to low or as we know it every pen by default to set to low we want to set them to high so that they don't what they basically don't what they basically don't display right here let me just set that to high now only the first digit should be working there we go the first digit is displaying really really bright nice it's going nice right here so actually for you guys to even see it let me just change the angle again just keep on changing the angle so you can see it there we go I think this is better yeah that is better you can't even see this one too you can see the there we go that's better now obviously let me just put back the code that I just commented out okay let me just put that back there we go and now let's just upload it so basically what happens is what we set this to low again then we set this to all of it to high so basically what digital pin one only displays and then we're going to set it for what the delay time is set to 100 milliseconds after 100 milliseconds what's going to happen is what we're going to set this again all of it to high the other digital pins I'm not going to write the same thing over again because I already set it to high and I want to keep it that way okay because I want to check what everything is working perfectly fine that's that's why I'm not going to you know write this again because I'm going to be setting all of these to high so they're already set to high so I'm not going to touch them that's what I want okay obviously if I want to write down something and stuff I'm going to turn it off but now I'm just using it for testing purposes okay so set this to low for the second digit and other them set it to what to high and give it a delay time and then do the same thing except for digital what digital sorry digital digit three again digit three we're going to do that for low we're going to set it to low and then obviously give it a delay Tye and then all of it to high and then finally we got to put what digit four to low basically turning on digit four okay and then having a delay time right here let me just upload this and let's see what happens all right can you see it it's scanning can you see it's going 8888888 I gave it a delay of 100 milliseconds okay that's how it's working let me just set this to again to a very small number let's say five milliseconds right now and let me just upload it when I do that let's see what happens when I do five look at it it goes so fast it scans so fast it just switches from one digit to another digit so fast that we cannot see it so we can just see is what we can see is that all LEDs are what turned on for us for for our eyes what we can see is what all LEDs are what turned on obviously that's not the case what it's doing is scanning it really really really fast just like how we did when when we put it 200 milliseconds you can just see the effect you can see the effect when you put it 200 milliseconds scanning it really really really fast look at it look at how it does it really fast really fast really fast let me just put it to 20 so you can see it even let's go let Let It Go even faster than it is let's go even one five times faster and look at it it's flickering can you see it how fast it's going it's just flickering we cannot see it we can see it it's going so fast but when we set it to five right now when we just set it to again five which is four times faster than 20 when we just do that look what happens right here we don't see any Interruption we just see all of them light up for our eyes we only see what it's all of it is lighting up because again our eyes cannot what they cannot comprehend that type of speed okay that's all that there is so everything is hooked up properly and as it should be okay with that in mind right now what we're going to do is to make this project interesting is we're going to be using a library not only that too if you remember when you were working with the let me just turn on the light when we were working with the Again One digigit 7 second LED display just focus on the focus on it when we working with it what we basically did was what if you remember what we basically did was what we just used 9 8 7 6 5 4 3 2 1 to just set a timer to just basically make a timer we just did was what count up to nine obviously this led segment can count up to what it can only count up to nine but when we go to the four-digit one obviously it can count up to what it can count up to 99,999 so just think of writing down and setting up all these numbers just think of setting up 9,999 going to 9,998 just think of even setting up all of that you know it's a lot obviously so in this case it's just way easier to use what libraries so they make our lives way way way easier okay so let me just go over to my screen again and what I'm going to do is let me just go over to my code I already wrote the code so again we don't waste time and we can focus on actually reading the code understanding the code okay so again I don't want to waste time by typing it okay there we go there's the code all right there's the code so one library that we're going to be using is you're going to go to your library manager and search for surf SE okay surf SE this literally the surf SE SEC is literally the library that we're going to be using okay it's not showing it oh sa s sorry I misspelled it SA sick there we go install it right here you can install it again if you cannot even if you don't find it on the library manager again you can go to what you can say seeg library and then afterwards searching for seeg look at it go to arduo page and then you can install it as a zip right here you can install it as a zip and then you can again add it to it you can add it to your sketch basically I think you guys know how to do it because I've shown you guys but even if you don't after you um uh after you're done doing that what you do after installing it is you say include libraries and add don't zip Library okay that's all you need to do but again you can just Again download it from here it's going to be easy let me just remove it for now so that I can install it as you can see all you have to do is just tap the install button and when once you're done there you go we're just done that's all we need to do there we go okay so the saf Library just helps us again work with LED matrices all right so it's going to help us as what it's going to be working with LED segments right here so it's going to make our lives way way way easier oh I think it's displaying 999 I'm just going to fix that up there we go okay it's going to make our lives way easier as I said again using libraries we're just going to what we're going to focus on actually work on a project and actually understanding lots and lots of Concepts because they're going to be lots of Concepts here okay so what I did again is here and my code let actually I can turn off the light uh no let me just keep it on it's just reflecting am let me just put it down there we go okay so when it comes to the code all I did is again set up the every segment right here with its respective pin and then again put again the digital again the sorry the digits right here set it up and I set up a delay time of five five milliseconds that's all I did right here what do we set up okay wa this is not supposed to be the this is not the oh this is the one that I turned on the all of the segments where where is that that other one there we go I want the other one I want this one there we go there we go all I did is again set up what I set up every digit again and again gave it its variable gave it a variable name and then what I did here is user input basically what this program does let me show you let me just show you the program ring let me just upload it first so you can see how the program works okay so it compiles my sketch okay it's done compiling now it should be done uploading okay so let me show you what happens again once you're done building the course what is supposed to happen so again we can set a timer for seconds maximum is what 9,999 9,99 so again we're going to set a timer in what in seconds okay so let me just set a timer for let's say 10 seconds I'm going to enter it okay after I'm done entering it it starts counting to 10 goes 8 7 6 and you can see five it's going for 3 2 1 and the buzzer should be ringing the buzzer isn't that loud let me try it again let me try one minut one second again did I flip it maybe I should flip it should flip my diode because you cannot hear anything maybe I again put the wrong direction on the diode because it can happen as I said let me just get the positive get the positive with this all right the positive there we go that's the positive I think I think it's the opposite direction so we're not hearing anything from the buzzer let me just say two seconds now two milliseconds we're totally not going to hear anything okay I'm using an active buzzer okay there we go and let me just check the polarity of the again the active buzzer the positive is supposed to be here let me just put the change the direction here too I think it's the direction right the positive is here the negative should be right around here okay the positive is connected the negative it's connected the negative terminal basically the G and D okay and then this is going to be connected to analog pin 4 I set it up as analog pin 4 let me just check it out bus pin set to as you can see unlock pin for let me try to upload this code again may it should be the uploading let me turn off my serial monitor first though let me first turn off my serial monitor before uploading it okay it's done compiling okay it should be uploading all right there we go let me just again set up for three three seconds counts three 2 one okay I think the problem is let me just go over to my try to find analog right okay let me just set this to 5 milliseconds this one to 255 yes basically 5 volt 255 5 volt yeah and it turns off after 5 Seconds of what 5 Seconds of playing a timer let me just do that going turn off my serial monitor fast before it it's done uploading there we go let me go back this code let me go up now let me go to my serial monitor let Set it three should be working come on Can You Hear It O I think you can hear something but it's not the best okay I think it's because this one is not connected properly I think one of them is not connected properly you know what so what I'm going to do right here is again search for analog right command let me just turn off this analog right let me just when it turns it off this is basically turning off your what it's basically going to turn this off after 5 seconds it's going to turn off what our uh our um our buzzer so let me just turn that off and let me try to wire up wire it up properly I think it's the wiring that's causing the problem let me upload this code first and then let's try to again use the timer let's just do that done compiling uploading and it should be done uploading okay let me set this to three okay now we can hear it continuously just correcting the analog pin for you can hear something can't you can you hear it so what happened again what did I say right here I said that when we're using what when we're using diodes what happens is what we hear it half the time musically okay we hear it half the time because again when it comes to each circuit it goes back and forth so going to only work what in One Direction let's say the back one works okay let's say the back one works the fourth one doesn't work okay so basically we're going to hear it for what we half the time okay so we're basically hearing it is what can you hear it it's not like the normal active buzzer sound but it's creating a sound why is that just think of it as if you're using uh a delay of what five uh milliseconds and then what giving it an off okay just turning it off on off on off keeping off doing it what for over what half of the period of tie okay just think of doing that it's basically that okay because it's turned off for what for half the tie as I said again when it goes to the other direction when the current revers in other direction it's not going to go to what to the buzzer why is that so because we have a what we have a diode okay let me just focus here there we go it is working okay so now let's focus on something else let me just turn off the serial let me just actually upload it again let me first turn this on so that turns it off after 5 Seconds basically like how a timer just turns off after a while it's going to turn off after 5 Seconds okay that's the code right here let me just go all the way up and let's start actually analyzing the code because it it does work okay I know it might seem a lot of code but I'm just going to explain to you what I just did most of it is copy paste so don't get intimidated by the like the amount of code that there is here okay so user input is what user input is basically the amount that we're going to be receiving from what from a user right here I'm going to save it so for example the number we're going to be receiving here if it's a 30 it's going to be what user input is going to be what set to what the 30 right here okay it's basically that okay this code is useless right here so I just removed it and there's bus pin right here which going to be set to A4 again I'm going to be using this obviously for my what for my buzzer makes sense and then I'm going to set there a delay time of 5 milliseconds okay then I'm going to what I'm going to include the sefc library right now the one that I again what installed in the library manager I'm just going to include it right here and right here it says is what SE seg SE seg right here again again the capitalization matters okay again you can read the documentation for yourself you can just say you can Google it yourself say SEF seg uh documentation right here let me just I already Googled it sa SE Library documentation and you can go to your to the GitHub right here and actually read what the SE seg is capable of okay so you can read it for yourself but I already read the documentation myself and I'm going to be what I'm just going to be uh using it for this purpose all right I just want you guys to know that let me just go to the there we go so it's basically what it's basically asking SE SEC right here to set up an object or a list called sefc okay it's going to be creating a seeg called list and we're going to be using this a lot like look at here I'm going to be using se. begin se. SE brightness SE seg do a lot there's even se. refresh right here set number refresh display so basically it's going to contain the commands of our of what of the SEF seg what library okay it's basically like how Arduino sets up you know how Arduino is like hey Arduino be like Arduino sets up what serial monitor okay it sets up the object called cereal right here a cal just like how we obviously this is automatic by the way just like how we use Cal and say do begin we say serial.println right here Arduino is basically what it's like Arduino what setting it to what serial I just want you to think of it it's like that equivalent all right but obviously Arduino does it what Arduino does it automatically we going have to touch anything but when it comes to libraries we have to do it ourselves okay we have to do it manually okay we're just setting up what saf s uh just think of it as a folder named SE SEC and it has a lot of files again okay lots of files right now okay I just want you to think of it like that okay so again we're going to see this as a what as a bite again as you remember we were talking about bytes when we were changing it to Binary saying eight bit 10 bit and we were checking that so basically a bite is literally what a single bite is eight bits okay so basically it's like eight bits of what information and we also saw how eight bits of information literally correspond with you know when we're working with with Zer up to 255 for what when we're using what analog again analog right command if for remember okay so we're using a bite okay so we're going to be setting this to a bite again okay and we're going to tell this and and we're going to set this is what number of digits basically what for example in our case we have four digits okay we have four digits it's going to be corresponding to what to one and eight if you go to your documentation right here it just tells you right here should be around where is it I actually saw there we go supports up to what 1 to8 digit displays okay I want you to understand that so basically what I did is what the number of digits that is on my what on my seven segment LED display in this case I'm using what I'm using a four digit seven segment LED display that's why I'm going to set it to what to four and then afterwards what I'm going to do is what write this down again digit pins and then what do I do I set it in order okay I say the digit pins what are the digit pins they're D1 I already defined them here they're D1 D2 D3 and D4 okay one thing I want you guys to understand here is order matters okay you're going to first put D1 and then you're going to put D2 and then D3 and then D4 okay you cannot jumble it up and then expect the library to understand which one's which okay it's not it's never going to understand that so again one thing I want you guys to understand is what D1 D2 and D3 and D4 are supposed to be set with in an order okay the same goes for segments right here when we said segment pins okay it's going to be set in an order why is that so it's important to be in order as I said again there are lots and lots of models of what seven segment LED displays okay there are lots of models of them right here mine has a different number which is 420 something and I didn't even find the what I didn't even find the documentation regarding my type okay so they're going to be lots of them that are manufactured by different again different companies okay they're going to be different where the pins are the pin placements are going to be what they're going to be different from pin from seg mment to segment okay that's why it needs to know which is which is which okay so you need to figure it out yourself as I said again You're going to figure it out yourself and then you're going to what Define it here and then you're going to put it in an order okay you're going to put an order of what a b CDE e f g in alphabetical order and then finally put your decimal point all right then afterwards there is again we're going to put the type of again um um the type of data we're going to store in this variable in this case Say Bo I'm going to I'm going to teach you guys what that means okay then it says resistors on segments are we using resistors on our segments yes we are so we set it to true true basically meaning what yes we are okay what does a bullion mean so a bullion basically means true or false okay it holds two values true or false so true basically means I want you to think of them as being asked as a question when you asked a question for example are you hungry you're going to say yes or no it's a yes or no question okay you're going to say yes if you're hungry you're going to say yes and if you're not hungry you're going going to say what no if you're fully going to say what you're you're going to say what no okay that's basically it but obviously different in what in computers basically you're asking our computer do you have resistors on your segment that's literally what SE is asking us and we're setting it to what we're saying yes we do we're setting it to what to True okay so this is basically booleans okay so even if you Google it for yourselves and say bullying values this is again basic computer and I think that most of you do not know don't have prior programming knowledge okay so right here represents a truth value that is obviously true or false okay that's literally what it is so to express booleans again they're data types just like how we have numbers and you know strings and all that there's something called booleans again they're data types okay I want you to get into detail right here they're data types and then we're going to represent it by what by using the word Bol okay that's one thing you should keep in mind all right then afterwards we tell up the hardware configuration ation is yours common cathode or is yours common anode obviously for those of you have a common anode you're going to be what you're going to remove this and say common anode there we go it's going to finish it by itself it has aut ofil so you can just finish it by yourself again capitalization everywhere matters so again make sure that you write it down in capital lers let me just put this back to Common cathode because mine is common cathode again if you have a common anode it's going to set it up to what common anode okay then as soon as what we're done doing that what we do is we set our what we begin just like how we begin our serial monitor we're going to begin giving our SE SEC the information we just set it right here what did what did we do right here we just set up the information in what in variables that's all we did right now what what are we going to do we're going to what we're going to give this information we're going to hand it over to what to se okay we're going to give it its Hardware configuration right here which is going to be common cathode we're going to give it the number of digits again which is literally four for our case and we're going to set our digit pins again we're going to give it our digit pins the list of Digit pins right here okay segment pins to and then resistors on segments one thing I want you guys to keep in mind right here is what when we put these again squared again squared uh uh brids right here okay when we put them okay one thing I want you to understand is we're just saying is we have a list okay this means is what we have a list we're going to be setting up a list okay so we're basically doing what we're just setting up a list we're just setting up a list of what a list of Digit pins right here so basically this does what it just tells Arduino hey we're about to what we're about to use lists in our code okay that's all it's basically telling you okay and afterwards once we're done again giving this information handing this information to sepc what do we do we set the brightness right here okay and I read the documentation and it should be around 0 to 200 okay it turns it lights up from 0 to 200 the value is going to be 0 to 200 right here but when it comes to 200 we're going to see something like flickering all right just like how when we're using uh when we were using uh let me just bring this right here and we set this to 20 when we set the delay time to 20 and we try to turn on everything and this to 20 and just like how we turn on everything we're going to see some flickering don't we I'm just to compile and just upload it okay I have the seral monitor open on this one that's why there we go now it should be working okay it's compiling and now it should be uploading it's like how when we're trying to do that it flickers a lot can you see it it's flickering a lot you see it right it flickers a lot basically that's what's happening right here basically it's telling us right here to use a brightness between I want you to do right here is listen um right here when we set it from 0o to 100 it's going to be perfectly bright but when we set it to something above 100 for example between 100 200 flickering again might occur okay so to prevent this I'm just going to set it to a value between zero and 100 right now just set it to 90 you can set it to 100 if you want to but again most cases don't use 100 to 200 value okay okay because it flickers a lot from my experience not only that too but it's also written in the documentation okay then afterwards we finally what start our serial monitor right here start our serial monitor okay then after we're done setting up our code right now what do we do now we're going to ask the question hey set a timer for what set a timer for seconds and the maximum is what let me actually set right here should put a comma right here makes more sense to put a comma uh set a timer for seconds the maximum is what the maximum is what 99,99 obviously the maximum is what 9,99 I'm just saying that okay let's just say again a user wants to use our again our Domino and set a timer let's just say that we're just again creating a product that is like the timer or something for again users a simple digital timer let's just say we're creating that for a user okay so we're going to ask set a timer for seconds the maximum is what the maximum is 9,99 okay I'm again printing the string out and then look what happens here there's a wild code right here there's a code right here that you guys don't understand so what I'm going to do right here okay just to make again our lives way simpler let me just get out of the sketch right here and try to explain it let me just open a new sketch and try to explain it inside of a new sketch I think it's going to make it way way easier let this load this some time okay it's taking a bit while there we go it's loading and let me just show you what I mean by what this Loop does right here what does even this code mean okay so first things first is we're going to be setting up our serial monitor okay serial. begin I just want you to follow along I don't want you to code this okay I just want you to follow and just give me your attention Okay then afterwards what I want you to do right here is we're going to write down while and then me go here and then right here set something called we're going to be using the serial again and we're going to saying available okay and we're going to set this to zero we're not going to set this to zero we're going to compare it to zero right here and let me just try to explain this code for you but before that let me try to print something without it so let me just comment this out basically let me just leave this out for now let me just try to print something let's see the problem that there is and let's see the problem it solves for us okay let's see what this Cod what this code solves for us okay so let me just again try to print what let's say uh let me just try to ask it a question right here Hi how are you okay I'm just trying to ask it a question right here let me set a semicolon right now and let's see what happens okay let me upload this and it should be done uploading it's compiling and it should be done uploading by now okay it's done uploading so let's see what happens here so let me turn on the serial Monitor and just go close to it and you see that it's printing out the same thing Hi how are you multiple times again and again and again can you see it just printing it out again infinitely so it's just going through a loop again printing it again printing it again printing it so just think of just being in a conversation and some somebody asks you a question what do you do you what you go silent and what wait for a response don't you you go silent and you wait for a response basically Arduino is what Arduino is basically asking us the question over and over again and just think of somebody doing that in real life that would be really really awkward and really weird really so anyways how do we stop ardino you know from telling us you know from um from again how do we tell Arduino to to again to tell it to shut up right now just hey Arduino I just want you to shut up until I give you a response how do we do that so obviously we're going to be using the while loop right here okay and we're going to be saying serial. available okay there we go equal to what equal to zero and then when we set it to here again what does it show right here basically now it's going to ask me one time right here okay so I'm just again remove the serial monitor when uploading it there we go ask me it asks the same thing there we go still uploading so right now what does it do stops asking me the question it just basically stops asking the question just asks once and then waits for my response can you see that it waits for me to enter a message right here let's say I'm doing fine doing fine and just send it over okay so waits for me until what until I'm done giving it a response right here okay that's what it does so again serial. available checks what checks the amount of information that is coming here through here so basically the amount of information that is being sent by our serial monitor right here in this case we're if we're not sending anything it's going to be equal to what it's going to be equal to what it's going to be equal to zero if you don't send anything it's going to be equal to zero when I when as soon as I send something though it's not going to be equal to zero right here let me just do that soon as I do that this will no longer be true so this while loop is no longer going to be true okay there we go now it keeps asking me the same question why is that so because it's no longer what equal to zero again the amount of information that I'm being sent by the message again by the serial monitor is what is no longer to zero I'm sending some sort of information specifically right now I'm sending what I'm sending a string okay so right here what does it do a wild Loop does again wild Loop does is again while is basically as I said again while hungry we can use this metaphor again while hungry eat okay so I want you to think of them as what while loop I just want you to think of them as what it going to it's going to keep on running this same thing and same thing the same thing over and over again until what this condition is false the condition that is here is what is set to false okay so let's say while we're hungry what do we do we keep on eating we keep on eating we keep on eating but as soon as we not we're no longer hungry basically we're full what happens we stopped eating okay so we stop this specifically what in this case what doesn't mean we're going to skip the code that is in between the curly brackets right here the curly braces right here so we're going to be what we're going to be skipping the code between it until what until that condition the condition that we set here is what it's false so so in this case it is true until what until I give it a message right here as soon as I give it a message though it's false right here there's nothing here so basically what am I telling it is basically wait wait for my response don't run any code just wait for my response and it's is going to keep on what running this on a loop on a loop again and again and again waiting for what for my response okay so it's was going to be waiting for my response and as soon as I respond to it it starts to what it starts to actually uh give me what starts to actually what starts to actually run the code that is below here okay so run the code that is found below the Ser what the while again the while loop okay the while loop is going to keep running over and over again it's not going to read the the code that's beneath it okay it's not going to be reading the code that's beneath it what is it going to do it's going to be reading again the while loop over and over and over again until what until I get a response as soon as I do it's going to go beneath and read the code that I wrote down beneath the W Loop okay so once you just keep that in mind let just go to our Arduino right here there we go let's go back to our actually go back to our code right here to our W Loop code okay just go here where is it there we go okay afterwards what do we do we take the user input right here and then it's set to what serial. parse int so what does serial. parse in mean so let me start from something you guys know and you guys learned about u in the previous few sections so one thing you guys learned about is what we learned about again setting up strings right here so we set up a string right here and then what did we do let me just give it a name user feed okay for now just give it a name let me set it up and then what did it do right here I'm going to do is I'm going to say user feed. what user feed I'm going to say user feed I'm going to set it to sorry I have to set it to something it's a variable I have to set it to something I'm going to set it to re serial. read string right read string basically what does this mean basically what it's going to read what the value that is going to come from here what do I expect to be I expect it to be what a string it's written right here I want it to be a string so if I display a value right here let me just say um I am fine to the serial monitor but before doing that I have to upload it let just actually upload it first let me upload it and then I can just run it okay it's done compiling and it should be uploading now okay it's done uploading there we go now let's go to our serial monitor there we go and what do I say I am fine okay let me just say I am fine right here here there we go if you just let let me just print out user feed right now it's better to print out user feed so we can see it ourselves let just say print Ln and say I want to print out the user feed after what after we set it up okay there we go let me just upload it let me close my seral mon till that time all right everything should be going good now it's not uploading now let's check what happens here okay let me just say I am fine okay it prints out out I am fine there we go prints out what I am fine nice so what does this mean again this is again used for what for Strings reading strings so if you remember what did it do it always made what created a new line always at the very end it created a new line for what for our responses if you remember create a new line so I can just say serial.print and again it's going to print it out in a new line if you remember not only that too but importantly right now what does it do it also sets it to what to a strength so even if I let's say give a value of 10 right here if I say 10 and just enter it over here it's going to give me what even though it looks the same thing right here it seems like the same thing it's giving me what it's giving me this what it's what Arduino is outputting is what it's outputting 10 what I want is what the number 10 it's giving me the text 10 right here okay you might not see from the serial monitor I mean for Ser from the serial monitor you just assume that oh it's just 10 no difference here but obviously what is it doing it's giving me the what the string 10 okay it's not giving you what the number 10 obviously with that case we cannot what we cannot you know multiply strings we cannot add up strings they don't have the properties of what numbers okay it's going to treat it as a what as a text our green is going to treat our 10 as a what as a text when we put it inside of a string it's going to be thinking of it as what as a text containing What as the text containing number 10 so it's not going to be able to multiply it to add it and this property is very very important because we're going to go here let me just go show you guys right here even in our sketch right here we're going to be using something called set number from what from our SE Library okay so we're going to be using set number so again when set number obviously the name self-explanatory we expect a what we're going to be setting a number right here okay so we're going to be expecting what a number if you put a string right here we're going to be what we're going to be confusing our SE Sego Library okay we're going to be getting a bunch of Errors okay so right here just to make sure that you know we're receiving number 10 and we want to even give out numbers is how do we tell Arduino that we're going to give it numbers instead of strings how how we're going to tell it that we're going to be giving it numbers is literally using parse int okay parse in it contains the the what the the the name int the integers it indicates what integers okay so we're telling our we know what we're going to be giving it integers okay in the message board we're going to be giving it what we're going to be giving it integers and most importantly I want you to store it as what I want you to store it in the variable as a what as an integer I want you to store it as a string I want you to store it as what as want you to store it as a number okay that's what we're telling Arduino so it expects a number not only does it expect a number but also what it also is going to be outputting it in again setting our variable to a what to a number okay so right here let me just say right here and parent I'm just going to say 10 right here and then it's going to give give me can you see it I just give it 10 right here just gave me 10 obviously I just said print right here not print Ln I said print right here uh so it's give me 10 and then ask the question again because obviously what because again it's running on Loop so it's going to be asking me the same question once it's done going through the loop okay so the main important thing here is what when it comes to parseint it's what we're going to be receiving integers on the message board that's where we're telling what uino okay so we're going to be telling ardino we're going to be receiving 10 not only that too but what we're going to store it at what as a number I want it specifically store it as what as a number I don't want you to store it as a string that's where we're telling ouro or obviously there's something called parse end and there's something else called parse float basically parse float is literally the same thing as parse ENT except for what it's for float numbers basically what decimals okay so let me just go back to parent that's one thing I want you guys to know okay so even actually we said that we Ed the while serial. available again this Loop right here we Ed it again to what for R you know not to asks the same question but it's actually important too in another aspect okay let me just remove the question right now again let me let me just show you why it's important too just go right here let me just dice it out again let me just take it out right now and let's see let me just upload it let me just try to set up a variable right here okay let's see what happens okay okay it's should be done uploading by now there we go and when we put on the serial monitor let me just again if you cannot see it right now but it keeps on outputting z0 z0 0 can you see it but let me just again give it a value right here let me just say 22 okay it's going to Output 22 and then it's going to go back to 0 0 0 0 what's going on you might be wondering obviously the problem here is what the problem here is what uino starts reading this code and for now what did we set uh in our in our message bar we did not set anything when we don't set anything what happens it's equal to what it's equal to zero so basically what it's going to Output zero can you see it it's going to be outputting zero and it's going to be printing it you see that right so what do what does it prevent to this wild. serial. available again code prevents to it's going to wait for for us to what for our message before what setting up our variable so it's important not only in asking the question for the question not to be repeated again and again and again but it's also important in what it's also important for us to what to set up our variables okay so it's just going to set it up to what it's going to be setting our variable before we give it a response it's going to prevent that okay so just keep that in mind okay so let me just go over uh go over back to our main code right here and let's try to read the other part of it so right here I'm asking it is is user input is what less than or equal to 99,999 because we cannot display anything beyond what four digits as I said again and and this symbol right here and then what it tells us is what user input must be greater than zero as you remember what it goes down it goes let's say if we have 20 right here we start our timer from 20 it's going to go 20 19 18 it's going to go all the way to what let's say it goes to 5 4 3 2 1 zero it's going to keep on decreasing so -1 -2 I don't want it to go to what I don't want it to go to negative numbers and zero because obviously time obviously cannot be negative okay so I don't want it to go to what to negative numbers that's why I always want to check before running any code I want to make sure that the user input is what has to be greater than zero because we're going to be what we're going to be decreasing one as soon as we go anyways one thing you always want to make sure is what it's less than 99,999 and then what less than or equal to 99999 and then greater than zero okay then okay these again this symbol right here let me start from the symbol right here I think you guys know obviously the if statement the symbol right here basically means less than equals to if you just go over here and U let me just go over here right now and let's go to less than or less than or equal to the sign if you look at the sign of it I think most of you are familiar with this in math we use this sign this symbol right here but we don't have the symbol in our keyboard okay so when we're coding we write it down is okay how do we write it down we write it down is what we put our again our first again less than or equal to whatever it is less than or greater than we put it first and then we put the equal sign okay we put the equal sign at the end okay so for something like greater than let me just try to write down greater than if you want to write down greater than or equal to we just put the greater sign right here and then we put the equal sign at the very end okay just want you guys to keep that in mind okay and what does this mean this basically means like the keyword end okay it just basically means end okay so right here what does this mean is okay if the user input is less than equal to 999 and user input is greater than zero it's going to what it's going to run this code basically if one of them is false what happens if one of them is false you know let's say the user input is less let's say it's less than what it's less than zero right here okay let's say it's even zero or negative number and this is going to be true user input is going to be what less than negative it's going to be less than or equal to 999 because it's going to be a negative number okay this going to be true but in this case what happens in this case it's going to be what it's going to be false it's not greater than zero a negative number is now what greater than zero so it's going to check what both of them are true so if only both of them are true it's going to happen what it's going to what it's going to be running this Condition it's going to be running this code okay this condition is going to be true if only both of them are true when we're using end okay that's how we express The Logical term end we just say we put double what we put double n signs right here and that's it okay just want you to keep that in mind when it comes to or obviously or when it comes to or let me just actually go back here when it comes to or we use this sign okay we use this sign it's found again above your Enter key and you just use shift and then you just again touch it okay so what does this do this basically means or okay and when it comes to or one of the conditions are true if one of the conditions are true it's going to be true so it's basically asking if user input is less than or equal to 99,999 either this is true or this is true if one of them is true it's going to run the code this condition is going to be true it's this statement is going to be what the statement is going to be true okay I want you to keep in mind this the statement is what going to be what it's going to be true so it's it's going to want want it's going to only want one true value okay when it comes to the end everything must be true everything must be true for the whole condition to be true okay all right just keep that in mind okay now let me just go right here and again right here we're going to be running the while loop okay so it's going to be going until this Loop until what until this condition turns out to be false so we're going to be checking again if this is greater than zero okay just checks for zero and then what happens it's going to set a number basically what it's doing is what we're telling what we're telling seeg hey I want you to what I want you to what to display this number okay send numbers basically I want you to display this number basically what is this the user input basically what the user just input it okay once you're done doing that what I want you to do is I want you to display it okay okay so let me just uh there's a bit of a code that is repeated over and over again this code is repeated over like 200 times okay this code like this specific code right here this two lines they're repeated again over 200 times so you might be wondering why did we write this over 200 times so let me just explain this to you so right here what people would have suggested was okay I want you is okay I want you to do a SE seg I want you to what I want you to refresh the display so let me just explain what refresh refreshing display speed refreshing display basically means when you're scanning again you're again if you remember when um when we're using a four digigit again segment display what happens we only turn on what one digit at a time so it's going to what it's going to keep on scanning basically what it's going to keep on running the same thing again again and again and again very very fast that we don't see it in our what you don't see it by our Naked Eyes okay basically that's what's going on so we're telling what we're we're telling SE I want you to physically what I want you to physically refresh the display okay I want you to do what I want you to do exactly what refresh the display again and again let's say for example we put a number for example this time is 20 how do we display 20 on the third digit what do we do on the third digit we put a what we put a two and then on the four digit we put a what on the four digit on the again on the display we put a what we put a zero okay so I wanted to what I wanted to basically refresh the display I wanted to go from two Z I want to go two Z two Z again and again because we can again as I said again we could only turn on one what one digit at a time so it's going to do it very fast so SE is going to automatically what it's going to again when you tell it again it's going to what it's going to refresh it again and again okay so most people would have suggested just me let's forget about the code that's beneath here okay so beneath the comment right here so what most people would have suggested was refresh the display and then okay you know what we have to set a delay for what for 1 second why is that so basically represents what after 1 second we just wanted to what we basically what representing one second of delay right here 1 second and then we're going to do what we're going to decrease it okay that's was basically what uh most people would suggest right here we're going to be telling what refresh the display and then delay it for a second so that it counts what it counts a second okay it counts a second on the timer and then what it can again we can keep on what we can keep on decreasing the user input value okay the problem areses here so okay let me just let me just think that Arduino is again reading this code so it's going to go right here and let's say the user input is what less than or equal to 9,99 yes it is let's say I just put 20 right here okay and is 20 greater than zero yes it is so it's going to read this code and then it's what it's going to be set the number to what it's going to be setting the number to 20 and then what it's going to be refreshing the display and the problem arises here it's going to read this in an instance it's going to read this in what in milliseconds okay it's going to refresh the display in milliseconds and then it's going to be delaying okay physically it's going to be delaying for what for 1 second so it's going to turn off the display and delay for what for a second so let's just say this again takes Arduino 5 milliseconds to read let's just say it takes a definitely less than that but let me just say it takes it only 5 milliseconds to read this okay how about this it's going to be spending okay it's going to be what it's going to be turned on for 5 milliseconds and then what happens is what for 955 milliseconds it's just going to be off okay it's going to be what it's going to be delayed okay it's going going to be delayed it's not going to be on okay we're not going to be refreshing the display as I said again it's going to be just delayed it's not going to be reading any quote for what for one second that's what's going to be going on okay so what is the right way of doing things okay what's the right way of doing things then the right way of doing things is let me just remove this code again the right way of doing things is okay we're going to put our seeg we're going to be refreshing it and then we're going to be delaying it for 5 milliseconds because we cannot notice 5 milliseconds when I put every everything as I said again let me just put this right here where is it there we go when we set the delay time here to 5 and we again uploaded the code let me just upload it okay there we go it's fa failed to upload okay I see I see why I fail to upload let me turn off my serial monitor right here there we go let me just upload this forget about the errors right now okay I should be done compiling and uploading if I just upload this right now can you see it it's going to go so fast that we cannot see what we cannot see change from one digit to another digit change from one digit to another digit and another digit again we cannot see it because it's going to what very fast 5 milliseconds is just so fast for our eyes okay so what I did was let me go back to my again normal code right here okay what I'm going to do for my normal code right here and then what do I do is I keep on refreshing the display and I keep on delaying it by 5 milliseconds okay I keep on delaying it by what by 5 milliseconds there we go so I keep on refreshing the display and doing it how many times 200 times okay this code is again written over and over again so it's written like over 200 times okay if you go all the way up to I think line 400 or something you can see the end of it but anyways it was written 200 times so obviously the simple question is is what's 200 * 5 200 * 5 is what 200 * 5 is 1,000 milliseconds basically what basically a second okay that's one thing I want you guys to keep in mind so right here I just keep on refreshing the display and then do what do a delay of 5 Seconds refreshing the display do it what do a delay of 5 Seconds and keep on doing this over again 200 times so how do we do this obviously again you write down what I did was what I obviously wrote down this code right here and then I started to what copy paste it until again to the point of where it reaches 200 again you have to again paste it 200 times I think you guys know how to uh you know place this 200 times really easily obviously what you do is what you write it down and then you P again paste it until it's 10 and then you copy the whole 10 and then you do what after you copy the whole 10 you paste it how many times 20 times so basically you just count up to 20 and then it's what it's 200 okay so you obviously you don't have to paste it 200 times okay you don't have to paste the same to these two lines 200 times there's an easier way to do it okay so right now let just go here there we go it ends here and then once I'm done again again displaying again my what I'm done displaying the user input for how much for a second for a total of 1 second again this adds up to a second I told you guys once I'm done doing that I want to do is what I want to minus one from the current value so right now I said it was 20 right so it's going to What minus 20 it's going to be 20 right here 20 minus 1 is what it's going to be 19 and it's going to set it to what to the user input it's going to set it to what to the user input the new user input is going to be what it's going to be the old user input right here minus one okay so it's going to be what if it was 20 right here it would have been what it is the the old the new user input is going to be what it's going to be 19 after we're done with that it's going to what it's going to refresh the display again all right and then what I wanted to do again is keep on running this wild code okay we do not finish the wild code right here this is a quote for another one but it's going to keep on running this while loop again it's going to keep on running this Loop over and over again until we reach what until we reach zero let me just go all the all the way up there we go it's going to keep on writing this over and over and over until what until we reach zero as soon as we reach zero it's going to be zero is greater than zero is that a true statement or a false statement is 0 greater than zero no it's a false statement and as soon as it hits zero what happens is what again all of this code all of this that is multiple lines again until the end of the curly bracket is going to be what it's going to be skipped and then as soon as we reach zero what happens is what as soon as we zero we're going to have what an analog right basically what we're going to turn on our what bus pin for 5 seconds and then we're going to turn it off okay so it's going to be ringing for 5 seconds and then we're going to turn it off okay then afterwards what happens here SE do blank what does it do SE do blank what what it does is basically it turns off every what it turns off the display okay so basically if it was displaying anything and if you just put dot blank at the end basically does what it's just going to clear out the display okay it's going to be turning off everything from the display okay so right here we're done with that and we're left with is only else so it's just the F if El statement right here okay if you want to see by the way the end of the curly brackets right here you have the rectangle right here right you have to find the other rectangle the one that is what the one is that is highlighted by a rectangle right here so this one is highlighted by a rectangle let me just find the other one that is highlighted by rectangle right now let me just go all the way up and as soon as I do that there we go can you see it it's what it's mapped with a what it's highlighted with a rectangle right here so basically what it's basically the curly bracket of what the if the if statement right here so we're saying if if it's 9,99 and again if it's greater than or equal to 99,999 and if it's what if it's greater than zero I want you to run this code but if it's not there's the else right here the else we just go all the way down because it takes a long while there we go if it's not you know if it's not be in this range what am I going to say I'm going to say his maximum number is 99,999 I'm going to tell the user please try again so let me just run this code right now let's just upload it okay all we need to do is upload it right now and now it should be working like magic okay and it's done uploading and now it should be working there we go now let me just say um 10 seconds should be counting to 10 actually I can turn off the lights too it's nice four goes to three two one and there we go the buzzer rings for what for 5 seconds and then what it basically turns off so there you have it this is the timer again made from what from four segments LED displays using the what the CF seg again Library anyways um this is one of the final end of the projects to be honest and this is personally my favorite project from the whole of the the whole course this is one of the hardest uh sections and actually one of the what one of the most rewarding and one of the best again one of the best project of section of this uh Sor course so anyways um see you in the next section in this section we're going to be discussing about Led matrices so you're going to be looking for again these do looking type of pins right here that have around eight pins here okay they have eight pins here and they have eight pins here so we're going to be looking for something like that okay so one thing I want you guys to keep in mind is while we're also working with the with the four segment right here so sorry the four-digit seven segment LED display one thing that obviously we had was the number right here so it varied again the positions of the pins varied again according to the number one thing I want you guys to keep in mind is again there's going to be a specific number associated with your what with your LED Matrix right here and then that number again is going to what it's going to be literally dictating which pin is which pin so first on let's just see what led metrics are even capable of so if you've seen a l Matrix it might look like something you've not seen before something that is completely new but if you again let me just go over to my screen and I think most of you are very very familiar with this these step type of ads and most of us see this type of these scrolling type of red LEDs have you you've seen lots of these led ads that scroll okay I think most of you have seen again these again red scrolling LED ads and they're basically the same thing obviously the the ones that are on the ads are obviously bigger and they're more capable but they operate on the what on the basics of this okay this is just that it's a very very small one okay all right so right here why do we use LED matrices first things first rather than these 4digit seven segment LED displays because we use this display again to display what we display numbers within any number that we wanted from 0 to 9 but obviously when you try to display uh something other than a number for example an alphabet we start running through errors okay so right here let me just try to display small a what should I even be turning on it's impossible to what impossible to what to turn on small a for example here what to basically display a small letter A okay but using an LED Matrix what we're capable of again we're capable of what we're capable of displaying any type of alphabet all right small letter capital letter uh any number and even small small types of images basically we cannot display a sophisticated image using this but we can display simple images for example a smiley face frowny face and other than that so we're going to display a little bit of what Smiley again again we can display what simple images okay so LED mat are more capable than what they're more capable than our four digigit again seven segment LED display we use this again when we want what we want to only dis play What numbers obviously they're no match to obviously they're no match to our again LCD screen that we have on our phones and tablets and laptops but they're way cheap and again they're going to show you the text when you need them so so okay so they're very cheap and again very very useful all right so now let me just show you how an LED Matrix works so before even you know using it in our project what we're going to do is check how LED Matrix work okay so let me go over to my presentation right here so right here is what they're marked every pen is marked with a what with column one column two column three all the way up to eight okay the same goes for rows they're what they're marked from Row one to row eight and one thing I want you guys to understand is row is what from left to right extend is from left to right while columns extend from what from up to down okay so if you go inside of an LED Matrix what you're going to be seeing is what you're going to be seeing lots and lots of wires let me just show you a wire right here this is basically the inside of what led Matrix you can see what you can see multiple lines here the ones that again extend the wires that extend from left to right are what they're rows okay they're going to be this lines again so I just want you to think of them as a grid okay they're going to be basically what a grid a grid of what a grid of literally wires okay so you can see this again they go to the corresponding number RS go from left to right and then there's columns Mark with a what Mark with a black color the black line is what columns and the red line is rows okay so how do we turn on a specific specific what a specific dot basically a specific LED inside of this led Matrix how do we do that basically what we do is okay we turn on R5 we set it to what we set it to high okay we're going to be setting up let's say for example we're going to be setting up R5 to high row five to high and then what we're going to do is what set column 3 to low when we do that guess what happens I want you to take a guess which led segment lights up is it this one specifically or even uh the the whole row lights up here the whole row lights up what happens I just want you to take a guess for those of you who guess that the whole row will light up you're wrong because what happens here is what the 5 volt is going to be connected for example let's say to this led right here the LED segment that's here but the problem is what it's not a complete circuit a complete circuit always has what it has what the positive terminal and the negative terminal okay so in this case it has the 5 volt again but it does not have what a negative terminal so specific here it's not going to light up the same goes for this one for these ones that are here but when it comes to the one that is again located at Row 5 and column 3 what happens is what what happens is what it lights up because why we have the 5 Vol coming in from row five and we have the ground pin the negative terminal coming from what from the column three so specifically right here it's going to what it's going to light up there we go it's going to light up okay that's one thing I want you to keep in mind all right so let's just move forward right here and let's try to draw an L okay let's try to draw a simple L um one thing I want you guys to actually keep in mind when trying to draw the simple else is what do we need to turn on we need to turn on R2 okay we need to set R3 to high we need to set R4 to high okay then we need to set R5 to high and then when it comes to the columns what happens we turn on C3 to what we we turn it on to low so basically what we create a full circuit for these four LEDs and then we set C4 to low and then C5 to low I think most of you would suggest me to do what to do this to get what an L but there is a problem here okay and this is literally what this is the result that we expect but what actually happens is what actually happens is it's going to light up like this why is that so right here unintentionally unintentionally we lit up what column 4 and row two Row three and row four are already set to what they're already set to high because of what we're again think talking about what column 3 but we already said column 4 to low so basically when they intersect right here basically what we're going to have a full circuit so when you have full circuit what happens in this case it's going to what it's going to light up so these LEDs are going to start to light up and the same goes for what C5 so it was more of like the problem that we had when we were working with the Ford for the four-digit uh seven segment LED displays you remember we did was what we tried to turn on everything right here we tried to turn on four of the digits right here when we tried to do that it started what started copying the first digit and the first digit started copying the second one and the second one copy the third one and the third one copy the fourth one basically giving us the same thing so for example if I let's say turn on seven right here and try to turn on all of this forage at once what we what are we going to be getting we're going to be getting s s s s okay okay that's what that's what basically is happening so if you look right here again what happened is what the column 4 what started to copy column three that's what's going on column four copied column three and column uh column again five copied column three can you see that what happens is there we go it started to copy it and basically they're literally what they're literally the same right now column 3 column four and column 5 light up the same okay so how do we prevent this we we do exactly what we just did when it came to what when it came to the four segment uh sorry four digigit seven segment LED display what did we do we only displayed one digit at a time and then we switched from one digit to another digit right so for example right here I displayed eight and then what did I do I moved to what I moved to here and then displayed another number for example let's say two and then after I'm done with that I displayed what let's say three right here and then I'm done once I'm done with this I displayed four but again one thing obviously Arduino did so good is what it was very very fast the Arduino was very very fast at scanning and again going turning off the first digit going to the second digit it was so fast that for our eyes we can see all of them is on so basically what we cannot see ardino physically doing what or you know turning off the first digit and going to the second digit it was that fast so we're going to be doing exactly the same thing here so what we're going to be doing is what okay we don't want again column four and column five to copy what column three so do what do we do we only turn on column three right here okay one part of the L we're trying to again uh write down cap capital letter L what we're going to do is what we're going to set up R2 up to R5 to high and then we're going to set column 3 to low so we're going to basically have what this line once we do have that we're going to what we're going to automatically what we're going to turn off what column three okay we're going to be what we're going to be turning all of them off okay so we're going to be turning this to what we're going to be turning column 3 to high and then what row two up to row five are going to be what row 12 to row five are going to be set to low then afterwards what do we do then afterwards we what we focus on what we're going to be turning on row five and then we're going to be turning off what we're going to be setting this to low and we're going to be setting this to low column four and column five so basically we have what we have an L obviously we cannot see it right now as if I'm just doing it separately but if I even try to use this on the presentation let me try to actually toggle between it very fast so you can see it okay so you can see somewhat of an L right here obviously I'm not doing it as fast as the Arduino when the Arduino does it it's going to be so seamlessly fast that we're not going to be noticing it but even right here you can notice a flickering L okay you can notice a flickering l so basically Arduino is going to do it really really fast and what so that we cannot notice it okay one thing again I want you guys to uh keep in mind right here is what the difference in the model there were lots of again difference in models when it came to the four segment U LED displays the 4digit 7 segment LED displays obviously the pin placement is going to be what different according to what according to the number you have again what I want you to do is what find the corresponding number in your LED matx I want you to find the corresponding number and then do what and then Google the data sheet if you don't have your data sheet you're going to be doing exactly what I just did for the what for the four digigit seven segment LED display we're going to keep on trying to turn on one segment right here one light as soon as we do we're going to be extracting what we're going to be extracting information right here let's say this one lights up in this case okay let's say this one lights up I'm going to see this is what I'm this is going to be what row six and it's going to be column 3 and I'm going to be again talking about the corresponding again pins that I again attached and obviously what do I need to do afterwards I can extract information and create a data she myself okay but one thing I want you guys to keep in mind is okay right here I can just say this is row and column okay I can just flip it again and say this is row or column I can just say this is again this is row this is column I can just say this is what this is row this is column so one thing I want you to get to always um um to always keep in mind is okay I want you to put the one that has a number right here it has faded what happened to mine was it has faded so I just put a black sign on it okay so to just indicate which direction is which so one thing I want you to always keep in mind is the PIN hits are supposed to be like this when they're on the opposite okay and again the one that has a number it's going to be placed like this it's going to be again placed what like this and then you can write down your pins okay so I want you to write down your pins like this so this is going to be what when you talk about Row one like this row two like this you're going to be keep on talking them like how you're going to be placing them like this this is very very important okay if you just do that you're going to be interchanging if you just let's say say not use this one where the pin heads are like up and top top and bottom and if you just place them left to the right when you when you place them left and right what happens is what the row is like this and then what we just interchange the row and the column they basically what they basically switch okay so just keep that in mind so always keep them from top to bottom okay when you're working with them okay so with that being in said before um we actually work in our first project let me just try to uh light up one LED segment right here okay so I get my LED again and because the LED takes a lot of space I'm going to be using a separate breadboard right here to make my life way easier let me just connect that breadboard to the LED first hopefully you can see it there we go connect it in such a way and then connect this right here around here okay I'm going to need my resistor right here obviously I need my resistor I just want you to think of them as what as LEDs if I just connected an led directly to what 5 volt and the gnd what happens to it it's going to what it's going to be fried if I brought my normal LEDs right here if I had one there we go if I brought my normal LEDs right here and just again connected 5vt and gnd what happens it's going to what it's going to be fried so I want you to think of them as what as LEDs right here we have 64 dots right here I just want you to think of them as 64 LEDs okay so right here what I'm going to do is put our resistors resistor right here there's a documentation right here x indicates okay X indicates row y indicates column this is my documentation my version of the documentation so I want let's say I want to turn on X6 okay I'm going to be connecting it to what I'm going to be connecting it to the positive While y is going to be connected to the negative okay so let me just do that X6 which one is going to be X6 X6 is going to be the one that is marked with a what that has a number for for you most likely has a number mine has faded so I just put a black sign on it so right here let me just put it back again I just removed it so I can show it to you guys let me put my resistance right here let me just make sure that it goes across because I don't want it to touch the don't want to touch the the other LED pins right here and then just do that okay that seems good enough for me then afterwards what do I do I need my gnd D I need to connect to one of the columns right here let me just um go to column wi5 right here let me just go to wi5 why not let me just do that let me bring two wires let me bring a red wire let me connect the red wire let me just focus it right here let me connect the red wire right here the red wire to the five volt all right five volt right here connected it to 5vt and then I'm going to be connecting my gnd D there's my gnd my handy gnd is here there we go and I'm going to be connecting it to the pin next to the very very left okay I cannot see it from this angle let me just it's very hard to see from this angle oh wait when I push it in just tap the there we go now it should be lighting up there we go let me just turn off the light turn off all the lights so you can see it there we go it's lighting up nice there we go it's lighting up uh let me just turn off the turn on the light back again let me just do that there we go and uh one thing I want you guys to keep in mind is what is this again let's count all the way again to rows if I count all the way Row three row four row five it's going to be row six again it's connected to what to X6 which means what x represents row as I said so basically what X6 is what row six okay it's connected to what column five all right let me go to column read it from up to bottom 1 2 3 4 and 5 basically this is what y5 there we go so it's connected to what column five and what row six there we go it's sliding up but one thing I'm going to tell you guys is all right one thing is this is how we're conventionally used to what lighting up our LEDs we first put what we first put our resistance and then put what the 5vt and then the gnd but we can also do what we can also do it another way we're going to be putting our resistor instead of placing it on the g& D right here let me just unplug my uino instead of what using the resistor on the 5 volt we can use it at the gnd D okay so let me just do that it's really hard to focus and film at the same time wiring it up is really the biggest problem when it comes to these led displays wiring it up is literally 90% of the problem in my experience okay there we go the resistor should be connected to the same okay there we go I think it is all right let just do that and there's our handy gnd D connected to that one and there resor is going to be what to the g& D instead of what instead of being to the 5V let me put the 5vt back to its place the 5V should be at X6 so should be at the one at the very very start just there we go the very start let me just go here and now let me just plug in my uino all right should be working okay it's not lighting up completely let me just make sure the even the resistance is okay there we go the resistance is the problem there we go the resistance is the problem but you can also wait let me just the resistance is keeps on it's not put on properly let me just take it off I guess it's not doing well let me get another resistor let me get another resistor right here does really hard to actually connect these pins and see at the same time it's really hard there we go now it's even lighting up really really good I don't think you might see it it's lighting up even way brighter than it used to can you see that it's lighting up really really good the last time I tried to light it up what happened when I connected the 5V when I connected oh let me just turn on the light so you can see better when I connected the 5 volt to the resistor it wasn't lighting up that good I can even see it myself it wasn't lighting up that good the problem isn't with the one thing I want you guys to keep in mind is it's way preferable to do what it's way preferable when it comes to LED matrices it's preferable to do what to go to what to use our 5 volt directly and then limit the resistance when it comes to the what to the ground pin basically to the what basically to the what to the colum okay that's one thing I want you guys to just keep in mind so again you can again wire it up as you like you can wire it up again put it to the what you can connect it to you can connect the resistor to the what to the 5vt but it's again recommended that you connect it to the what you connect it to uh the gnd okay because it's going to have what it's going to have more consistent lighting and it's going to be more brighter especially when you're lighting up lots of LED matrices at once anyways this is it for the section where we're actually going to be again checking what led mats are and just introducing it but we're going to work uh on a final project before again uh before again uh moving on from our LED matrices so uh see you in the next section we're actually going to work on a project involving uh LED matrices okay so I were I wired up the U LED Matrix as you can see here so let me just try to explain um what I did right here so I just again wired it up earlier because it takes a lot of time to wire it up because there's like eight pin from the top and eight pin from the bottom so to of 16 P so it's going to be a really really it's going to be a big effort to do what to actually um connect the what connect the El Matrix again to our Arduino okay so right here again this is my um let me just bring this bit back so you can see it this is basically my what this is basically my documentation on what the documentation I made on my uh on my LED Matrix okay so right here is what this is row four connected to the black one I'm just go right here so you can see it connected to the black one and then the white one I keep connecting this again with the parallel wires that are here okay I'm just going to be connecting it the wir that are next to each other so I keep connecting it all the way up to here and then connect it starting from what digital pin uh two okay so I keep doing that and then once I'm done with that there's going to be two pins left here these two pins right here these two um wires left here and I start from here and again what do I do I keep going on again I keep going on obviously the wire ends at at 10 I connected eight here then I connected two there's a total of 10 wires here okay so what happens is what I start using the normal wires as I said again so I run out of it so I use my normal wires and keep what and keep adding it up until digital pin 13 after digital pin 13 we run into a problem what is that problem we have 16 pins here okay we have 16 pins and right here how many pins do we have right here in the uin know digital pins we have around how much maximum of what maximum of 13 in my adino Nano specifically in my adino Nano there's a specifically what there's specifically the maximum is what 13 what digital pins okay so we run into this problem so what do I do I try to use the analog pins afterwards so I start to use the analog pins I think starting from A2 let me check at starting from A2 I start to use the analog pins okay connected them again it's going to be what different again how you it up again is going to be different from person to person depending on the model of what the model of LED metric you have obviously they look the same but obviously the number again is going to what it's going to affect where um every other pen is going to be so every column right here is going to be what my column one is going to be here right here at the very edge but for somebody else it might be somewhere around here or even somewhere around here so obviously the placement of pins and the placement of columns and rows and the pins is going to be different depending on the what on the number you have the model of what the model of the LED Matrix okay so I just want you to keep this in mind so again this I made is again specifically for me how do we know that I already showed you guys what you need to do is keep on wiring it up until one lights up as soon as one lights up what happens as soon as one lights up we can extract two information from it we can extract the row and the column okay okay so with that in mind okay let me go over to my code and to even check that everything is wired up properly what do we do we're going to need to turn on every LED Matrix right here we're going to need to turn on every column and every row just to see that everything is wired up sometimes again what happens is what the resistors again they might be attached together sometimes they're not put in properly and sometimes we run into what physical errors so sometimes it might confuse us where the errors occurring so your code might run perfectly and then again you might have a problem when you're working with the LED Matrix it happened to me when I was working with the uh four what four digigit seven segment LED display okay so with that in mind how do I turn on everything so let me first again there's I defined them earlier right here so I don't waste your time trying to do that so I Define them right here basically when you use the keyword hasht Define it's basically like using variables instead of here they're going to be what they're going to be set to constants variables are what they change from time to time again you can add them up you can what you can change them but when it comes to what when it comes to constants they're always constant I just want you to think let's say the constant of gravity is what we're going to say hash to Define okay I'm say hash to Define for uh the work anywhere hash to Define we're going to be saying gravity gravity is a constant what is it it's 9.8 9.8 m/ second so we're going to be defining constants okay so it's exactly going to do the same thing as what the same thing as variables but it's going to be what it's going to be set to constant it's not going to be what you cannot change the value once you set it okay all right so I just set this up again I Define the row one up to eight and what again pin they're connected to and then column to what column one to eight I just what I just rolled them down okay so right here what do I need to do is what I need to go to pin mode and then what start giving them output say they're output I want to use them as what as output okay let me just keep doing that let me keep on pasting it until and then go to row two and then Row three row four row five row six seven and then finally eight I'm going to be doing the same thing when it comes towards what when it comes towards oh wait I'm not correct here when it comes the same to the what to when it comes to the columns too we set all of them to what to Output that's what I want to do I'm going to be using all of them as an output okay so let me paste this again keep on pasting it and I think this should be eight let me go two right here 3 4 5 6 7 and then eight there we go now afterwards what do I want to do turn all of them on as you remember we're going to be setting what the rows to high and the columns to low to light up what to light up even a segment of the LED Matrix if you remember so to even light up everything I need to set all rows to high but one thing I want you guys to again pay attention here is we used analog pins and also what we also used digital pins so depending on the pin that I have I'm supposed to say I'm supposed to be saying what a analog right for analog pins and for those who have again a digital pen I'm going to be saying what digital right okay so I just want you to keep that in mind so let me just say dig the right right here oh it's changed my language Let me just there we go uh let me just turn this caps lock off there we go digital right then let's just check which rows receive digital right so all of them seems to be receiving digital right except for row five and row eight so except for row five and row eight I'm going to be saying this to right I'm going to be starting from Row one row one and setting this to high and let's keep just pasting it a bit there we go and now for Row one we're going to say row two 3 four we're going to skip five we're going to be using analog right for five then we're going to go six seven we're not going to be even writing down what eight eight is going to be using analog right so let me go here and say analog right and then if I set this let say set it to row five right here and then I cannot use high when I use analog right I'm supposed to be writing down a value which is going to be an integer between 0 and 255 obviously High means what 255 so I'm just going to be setting it to 255 right now and then once I'm done doing that what do I do I'm going to be also copying the same thing for row eight row eight said that high obviously right now oh I'm supposed to say 255 I said High instead of 255 my bad um so after this obviously our job is not done now we should set what the columns to what we should be setting them to low or basically G and D okay so column uh most of them seem to be using yeah yeah only two of them don't use it and this time they're what column 3 and column five okay so okay for columns what am I going to say they's still right most of them going to be using digital pins again it's because I run out of them that we're going to be using analog wrs so if you if you guys have an analog pin did again you're Arduino again your type of model that has more than 16 pins I suggest that you use only digital pins okay mine does not have it so I'm going to be using analog pins too because mine is a bit small okay so let me just set column one to low we set that to low let me focus on the numbers here one number okay there we go column one two okay column 3 and five are not going to be what they're going to be using analog analog right so except for them three and five I'm going to be using everything so let me go to column right now let me go column two three is not going to be using it so I'm going to be skipping three and going into four and also five we're not going to be what we're going to be using analog analog right and then seven and then eight let me just remove this code all right there we go now I'm going to be writing down analog let me turn off caps lock analog right column we're going to be starting from column three and then setting it to what to zero zero corresponds with what with low all right and then copy this and then do the same thing for what column five there we go and now I think everything should light up let's just upload the code right now it's done compiling and it should be done uploading can you see it almost everything's lighting up let me just turn off the light for you guys so you can even see it better and change the angle here it's not the best of angles there we go let just move it a bit there we go you can see that um row what a column what column 1 2 3 column 5 is not lighting up so basically I've touched the resistor or something most of the case again resistors uh they're not put in properly so let me just check my documentation right here to understand which one is causing me some problem right here okay so column column five should be around uh should be around it's not here okay it's here there we go column five is here so the resistor that is at the very front right here let me just turn on the light so you can see it there's a resistor at the very very beginning there we go at the very very beginning let me just turn that off there we go to just touch it a bit don't touch the other ones there we go just touched it a bit let me turn off the lights so you can see it better now now everything is lit up there we go everything is lit up okay so everything seems to be what connected properly so every column and every row was connected properly okay that's good now let's try to again do something interesting with it so obviously let's try to do what a project with it so right here what we're going to do is okay I'm going to be having uh I've tried to actually U search for libraries okay I've searched for U um LED Matrix Li liaries just like how we had the safe seg library for uh the segment LED displays the seven segment LED displays I Tred to find LED Matrix libraries and when I did that what I found was most of them required something called a Max 72xx chip basically it's not going to be your typical what your typical LED matrix it's going to have some like some add up to it all right so it's not going to be exactly the LED Matrix that we're using right here okay so it's limited to to what to the again the models that are what the models that are popular mine is a bit of a less known model okay not only that too but it's going to include its own chip so it's not going to what it's not going to include the traditional LED Matrix when I look at most of the what most of the libraries okay so what I did was let me just go over to the code right here let me go over to the code right here there's a code right here that is preset okay I don't want you to focus too much on this uh what all of this is but there's a preset code right here that I'm going to be leaving down in the link below in the link below in the description below so again you guys can see it and you guys again can use it for yourself so you can again get the sketch for yourself okay so let's just analyze the code though we're not going to be just giving you I'm not going to be just giving you the code okay I'm just going to let you analyze too what you need to analyze okay so let me Focus right here so let's start with it's going to be defining again your row so again with your corresponding Row for example it's at Pin five right here if you set it to pin five you're going to say pin five mine is set to pin six so I'm not going to touch it you're going to be defining your rows and columns and what pin they're connected to okay okay then afterwards what you're going to be doing is defining the rows and this one again is going to be written itself it's going to be preset again when you again look uh when you check for when you check the code in the link below so don't Focus too much on this but what this does is basically it's an object okay I just want to go over it so this an object that's again contains what this is a list that contains what it's a list that contains what row one row two Row three row four row five row six row seven and row eight at what at a list at a single list okay so it's just listing what what rows we have here basically the ones that are right here okay all right the variables that are right here let me just skip this right now I'm going to get back to this okay and right here what is very very important for you guys is okay what is very very important right here is again we're going to be setting the pin mode to what to all of them to Output what all of them to what to an output that's one thing I want you guys to do okay then afterwards okay I don't want you to focus on these two codes okay they're going to be pre-written again on the code I don't want you to focus on them they're been more complicated again so don't focus on them okay just leave them alone as they as they are okay we're just going to be using them as a library okay when we use libraries again we don't look at what most in most cases we don't look at what the behind code of like how the library works okay we don't do that what what we do is what we use the what the library what it provides us okay so like that again we didn't play in the library so what I did is is again this is all set up for you guys so again don't focus on these okay they're again beyond your scope okay don't focus on these they're going to be written down for you guys but I want you to focus is uh right here I want you to focus on this this uh to understand this what we're first going to do I think for you guys to better understand this is let me go right here and I want you guys to search for an LED Matrix matx okay LED Matrix right here and I want you to search when you come to LED Matrix editor Okay add editor and search for it and then go to the link right here and then you have your own what digital LED Matrix okay so what I want you to do is right here okay what I want you to do is what it's way better to draw it right here so let's say I'm trying to draw L like we did last time so I just showed you guys the science of drawing an L so let's say we want let's say we want to draw an L so the problem here Aris this is what we're going to have to what we're going to have to first what we're going to have to first turn it on before what visualizing okay so even to CNL right here what should I do I should visualize it myself before what before actually what before actually turning it on myself all right so the problem here is what the problem here is what we cannot visualize it we cannot visualize the what how to draw this in dots okay we cannot visualize how to draw this in dots before what before putting it in our what in our physical again LED Matrix so what this allows is what we can visualize how an L is supposed to look like so we can first do is okay so what I need to do is like this then I can know what okay I need to turn on column three and uh what row three again and I'm going to turn on row four row five row six and then after I'm done with that what I'm going to be doing is okay I'm going to turning this off I'm going to be giving it a delay time maybe a 5 Second 5 milliseconds okay not 5 Second 5 milliseconds and then I'm going to be running this code right here okay so I'm going to turn on row what row six and then I'm going to be turn turning what uh column 5 and column four and column 5 to what to low okay so I can visualize it so before even writing it down again in dots you it allows you to what to visualize it and the best part about this is what the best part about this is that once you let's say okay I wrote down L okay let me just write down l or something let me write down capital L let just write it down the best part about this is okay what you're going to be saying is insert inserting it after you insert it okay after you insert the code right here and you can see it right here okay and after you insert it what you need to do I'm just actually delete this I don't need this one just delete this one there we go once you have again this uh L again what the best part is as soon as you just go right here the code is written for you obviously you cannot understand what this is but as soon as you just touch as bite Ray it's going to change it for bytes for bits of data okay as a bite once you do that you can get this code right here so I can just copy this and then what you can just basically do is paste it okay to your code basically directly without without yourself doing it again without yourself saying okay I have to turn on three and then what two to low and then keep on doing this and this and this is going to what involve a series of steps okay just not to do that what you need to do is what what you need to do is only use this in what in bits so first things first let me try to show you guys what this means so let me just analyze one of these codes for you guys so I think it's better that way okay so right here let me start right here let me start all the way to the top okay there we go we have a right here can you see a can you see a okay let me start with b actually a is a bit of a the code is not right because I was messing around with it I remember that so I'm going to fix it though on the on the description code I'm going to be fixing it on the on the final code but right here let's see B right here okay I think B is something interesting to analyze so what does it do it says b okay bite it said to bite a bite is what a bite is basically eight bits just like how we were using again uh the number from 0 to 1024 if you remember numbers from 1024 basically these numbers from 0 to 1024 they were what they were eight bits okay so basically for example 1024 in 8 Bits or in a bite it's basically what one one one one one written down eight times okay when it comes to zero what was it it was Zero written down eight times and obviously 10 0 to 1024 again the values again are going to be converted okay that's basically what it is okay so again we' we've discussed earlier we've discussed about a binary so this is basically binary okay okay so what you do is B and what do they have is right here is a b they use a b or a small B right here to Define what we're telling our adrenal we're not just setting down random numbers we're setting down what we're sending information in what we're sending information in bytes okay we're sending our information in bytes I want our wein know to know that so you can use what zero B with a small b or you can use capital B right here okay then what do you do right here this this defines every column okay this defines every column so this is going to be for Row one okay this is the first one in our list this is the first one in our list so it's going to be what row one okay this is going to be row row two this is going to be Row three row four row five row six row s and then finally row eight okay so right here what we're telling is okay I want you to turn on what I want you to turn on Row one I want I want I want you to turn off what row one I don't want to use what when you set it to zero it's basically off I don't want to use what row sorry column one I I don't want to use column one for Row one we're setting this up okay this is again the whole thing is what the whole code right here again the whole thing is for Row one okay I want you to keep that in mind so every bits of zeros and ones is what every bits of zero and one is what every bits of zero and one is columns okay so right here I'm saying is for Row one I want you to do for Row one is I want you to what I want you to turn off what column one basically what basically I don't want it to light up okay I don't want it to light up okay when it comes to what column 2 column 3 column 4 and column 5 I want you to turn it on okay basically what it's going to light up I want you to light up what column three column four sorry column two column 3 column four and column 5 when it comes to column six seven and eight I want you to turn it what to turn it off basically what I don't want you to light it up okay that's what it's basically saying okay so right here I want you to do to do is what I want you to turn on what I want you to turn on column two 3 4 5 let's try to do that ourselves right here on the editor so we can see it ourselves so let's try to turn on let me just clear this let's try to turn on column 2 3 4 and 5 okay for Row one so let's go back to our code right here so that we can understand what this is okay there we go we again Define 2 3 four and five all right then afterwards for row two what I want you to do is I want you to turn off what column one and then turn on what column two let's turn on column two right here column two is turned on on row two we're going to be turning on column two let's visualize what's going to happen let me go back to my we know right here no it's the other code let me go back to the other code there we go and then I want you to turn on turn off what column this is column 3 four I want you to turn it off and then finally I want you to turn on column what column five let me just count it let me just see if I'm correct one 2 3 4 yes so I want you to turn on column five let's just do that let's go back here and turn on column five There is five and then let's go back to our Adeno code we're just going to analyze it again just to see how it works and then I want you to turn on what column two and column uh column 5 column two and column 5 the same thing as we did right here I want you to turn on column two and column 5 okay for Row three I want you to turn on column two and column 5 all right I just did that right there let's go back to ouro then afterwards for row four I want you to do is what I want you to turn on column 2 3 4 okay column 2 3 4 let's just keep that in our head two 2 3 4 2 3 4 there we go and then what do I want you to do right here let me read it okay we we read what row one row two Row three row four we're on row five right now let me just check it again yes we're on row five there we go row five is here okay now what I want you to turn on column two and then what column two and column five again okay I'm turn on column two and column five just like how we did for row two and Row three okay so let me just do that column two and column five column two supposed to be here and column five is here there we go and let's go back here then afterwards what do I want you to do column two and column what column is it column six we count it column two 3 4 five and then yeah column six so I want you to turn on what column two and column 6 okay let's just do that right here column 2 and column 6 for row six column two and column 6 all right looking something like an R right now let's finish it up so hopefully it's going to appear as B there we go I want you to do is what the same thing if I'm correct it looks exactly the same let me just check it yep I want you to do the same thing let me just check it again column two this is column two and this is column six so I want you to turn on column two and column six okay I'm just go to column two and column six column two column 6 there we go and then when it comes to the row eight let me go to the row eight right here the final row I want you to do what I want you to turn on column 2 3 4 5 6 so I'm just do that I want you to turn column 2 3 4 2 3 4 5 6 and there we go we have what we have somewhat of a b right here this is basically what's going to draw if I tell it if I tell it to draw B so what you need to do again to draw something is okay we have the information again preset for you I have the information preset for you I have B right here here c d everything from A to Z from a to capital Z I have it written for you guys okay from a to capital Z is written for you guys okay then what I want you to do right here okay is you're going to say draw screen and then you tell it I want to draw a b let's see what happens right here let me just upload this it's compiling and it should be done uploading that's all you need to do I want you to do is what use the function draw screen and put what again what you want to draw right here as soon as you set it at bytes right here once you set it to a bite what I want you to do is use it okay there we go draw screen B can you see it let me just check if you can see it let me turn off the light for you guys let me bring this closer actually bring this closer I don't want to touch the wires they're very very fragile I was about to push them away for you guys but they're very fragile because I can just ruin the whole thing and I don't want to again connect 16 pins it's going to be a lot of work let me just go from this angle so you can see it there we go I want you to focus on this there we go drawing out the be that we just drew on the water on The Matrix editor basically on our what digital Matrix so let me just zoom this back okay that's good all right so right here we draw B and I already said this said this for you guys so again you can write draw what d e anything let me just upload d right here let me just I want to draw D let draw a d right here there we go we have D drawn out for you guys so almost every letter is again I already preset it so what I want to do here is again we can use this to do what we can use this to again set up what not only letters we can also use it to even do what simple drawing so what I'm going to be doing is I'm going to be drawing a simple face right here I'm going to be trying to draw at least at least I'm going to be trying to draw a a face right here let me go to L right here let me delete it I don't need it anymore I don't need it let me just delete it and let me just reset everything once I'm done doing that let me just try to draw a smiley face not the best drawer but okay let me just go right here and let me start like this I think it's better that way let me just keep on trying all right let me go like this and then let me just try to do exactly the same thing here it's bit of a struggle because I don't know how to uh I'm not the best draw right here okay I mean it's not bad it looks like a good Circle not the best one but I think it gets the job done okay let me put two right here eyes and then let me just try to draw a smiley face on it let me just try to do that there we go we have what a smiley what we have a smiley face right here we have a smiley face so let me do is insert it right here okay once you just insert it the code is already written for you guys so again lighting up all of these individual what individual again um individual what individual uh bits of dots would be really hard because you're going to have to do what a lot of what a lot of work just to even light this up just to know which one's which and if you mess up a one spot you have to go back check everything again you have to do almost how many we used around let's say half a fit right here we used let's say roughly I would say uh maybe uh two two5 of the 64 again dots that we have here 64 bits of what bits of again lights that we have here and basically if we just again try to do it physically again set this to high set it to low and doing all of that it would be a lot foric okay so we're just going to be using this and you're going to be extracting this information right here okay that's all you need to do once I insert it the information that's out going to be right here it's already going to give me the code right here again make sure it's written down in bytes and bite erases this is again selected just make sure that this is selected let me just copy that let me just again let me only get the code right here copy that okay let just copy that and uh let me go right here oh not this one one let me go right here there we go and what I need to do is what I add it as as a bite okay as a bite of information so I'm just going to say bite and I'm going to say let me call it smiley because it's smiley face so let me just call it smiley and then again I'm going to need to again use again what my what my brackets right here just to indicate it's a list and then afterwards I can paste it there we go let me just again I don't want it to be spaced out so let me just give it space right here let me just make sure that again it can take up a whole line This is valid but again from an aesthetic point of view every every what every what every row right here is taking what a line up so it doesn't look that good let me just again without touching anything just remove the extra bits of the extra bits of again spaces right here let me just remove them okay I think this is good okay I have to remove this one that is here remove the extra bits of again there we go the extra bits of spaces that we had here now this looks better and let me just upload it right here let me just upload the code oh I forgot to do I forgot to give it a what the suic callon at the end I defin it right here smiley it should be working it's done compiling and now what it should be done uploading okay let me go to draw screen and I want to draw what smiley smiley let me try to draw smiley right here it's done compiling okay now we should be uploading and there we go we have smiley face can you see it let me just turn off the the other light not the best lighting but I just want to make sure that you see it for yourselves let me bring it closer so you can see it there we go we have a smiley face right here so again it's up to what it's up to your imagination again to do these things so you basically can do what you basically can do obviously you cannot do everything but you can do lots and lots of things it opens possibilities that were no longer possible in what that were not possible using a seven segment LED display so what I'm going to be giving you guys to do is what right here again I have the preset code what I want you to do right here is okay I did not add every alphabet I added every alphabet like every capital letter from A to Z as you can see right here added up and just set it up right here for you guys but one thing I did not do is I did not finish there we go where is it I did not finish writing down every small letter okay I have a right here but I did not finish writing down everything we have a b c d e and I stopped at stopped at J okay what I want you to do is add up to it okay I want you to add it up all the way up to Small Z okay I want you to add up all the way up to Small Z and one important thing I want you guys to do is okay again one thing I want you guys to do is don't Focus too much on this code but what I want you to do is write down a word with it how do we do that how do we write down a word uh if you again what I want you to do is we want to write down a word how we display a word okay how do we display a word I want you to think of it so again I want you to pause this video think of it for like at least a minute or two and then come back this video where I'm just going to show you again how we just do it because we've learned this so far and it's going to be very very simple okay so I'm just going to be waiting and hopefully now you have again resumed the video and then hopefully you got it right obviously to to write down words they're what they're just a bunch of what they're just a bunch of letters so what do we need to do let's say I want to say the word Arduino okay how do I do that I say draw screen draw screen a and then I give it what a delay time a delay time of what a few seconds right here 20 maybe 200 milliseconds I want to draw it for a and then what I want to give it a delay of what maybe a delay of a bit while and then give it some delay right here and then what live a delay of some some bit right here let me say 20 milliseconds and then I want you to draw screen d d right here draw screen and then B I already wrot down capital B so I can see oh I said b instead of r r after a is R let me give it a let me actually give it a draw screen of what a draw screen of uh B okay let me set this B right here no sorry draw screen I said draw screen again I meant the delay time sorry delay time of what a delay time of plus 20 milliseconds what what is better if I do it right here if I give it a variable say delay time and give it a variable so let me just select both of them and just say delay time delay time what also did I do wrong right here the code right here is not supposed to be set to delay time it's supposed to be set to delay I said delay time instead of delay my bad there we go now let me just Define this here let me just Define it maybe down here let me just Define it right here here say integer integer delay time let's set it to 100 MCS and let's try to upload this see what happens let me just try to upload these two again sentences right here this two letters it goes too fast for me okay let me just give it a bigger delay time let's say one second okay let's say one second see what happens St compiling can you see what's going on it's basically turning on it's doing the draw screen thingy and then what it's going to be delaying physically for what for a second and then it's going to be drawing again R for for a very very short while and then again it's going to have a delay of what one second where it's going to be what when it's on the delay it's going to be what turned off okay so what I want you to do again I'm not going to do it myself but your homework is going to be okay to find a way to delay it in such a way that again you don't do what you don't uh you don't do what it does doesn't what it doesn't turn off okay how do we delay it in such a way that it doesn't turn off so I want it to turn off for what for at least what for maybe a second okay I want I want it to be on for a second then I want it to switch to R not obviously again it appears for a second right here it appears for like uh millisecond right here and then what it turns off for a second and then it goes to the other R and then it turns off for a second so I don't want that to happen so I just want it to be on until we switch to a what until we switch to a to a to a delay so this is going to be your homework for this uh section so again I'm going to go to the next section and fix it myself but I want you again to try to do it yourself so before you guys again check out how I do it I want you to try again I want you to try hard and then to do what to and try to again solve it for yourselves okay okay so now let's analyze our code right here draw screen and then it does it again at for milliseconds and then it delays physically where it's going to be turned off it's going to be delayed for a second right here and then basically what it's physically turned off and then the draw screens are and then it's physically turned off for a second so best thing actually to do right now is let me just remove all of this code because it's not working let me just remove it let's go back where we were just drawing a specific ladder what happened here for example right now I'm draw screening what a what happens it draw screens a but it goes inside of a what remember the loop function in the ardino what happens it keeps running over and over and over again it's basically a loop just how it says it's going to be going over and over again again if you remember our setup code is here what setup ones when we go to our setup right here our void setup okay when it comes to void setup what do we do we only have what we only run out one time okay when it comes to the loop we keep running it multiple multiple times that's why when we draw screen let's say for example only a no delay time on it we can see a just being drawn right here there we go a is literally what is drawn on the screen again it's going to do what it's going to draw screen a for an instance and then it's going to keep on doing it inside of the loop again and again and again and again and again so obviously it's going to be too fast for our eyes okay so now the pro the question is going to be what the question is going to be how do we create our own Loop because when it's inside of a Loop it does what it literally what lights up so how do we create our own Loop how do we do it we use the while keyword okay so what I'm going to be doing right now is I'm going to be trying to maneuver it in a different way a bit of a different way but what I'm going to be doing is I'm going to be setting up an integer right here integer and call it I okay let's set it up and I want to set it to zero okay then what I want we know to do right here is I wanted to do is as long as I is less than 300 I want you to continuously what draw a that's what I'm saying as long as I is less than 300 I want you to do what I want you to draw it okay I want you to put what draw screen a keep on doing that okay that's what I'm telling mardino to do okay then what should I do right here it's going to be an infin Loop if I do this what is going to happen I is always going to be less than 300 if if if you remember because I set it to what I set it to zero so I want this to end at some point how do I do that then I'm going to say I keep adding one okay keep adding one every time while I does what while I keep adding one on I every time that's what I want them to do at the end of the loop okay then it's going to what it's going to end after what running this Loop 300 times it's going to run the loop around actually 299 times not 300 299 if I wanted to run 300 times I'm just going to set it equal to right here and then now it's going to run through the stop 300 times okay before what it's going to be drawing screen a 300 times before what before uh moving on to the other code so let me just try to even upload this okay we're running into an error okay I see I see where the error is occurring so right here I said integer to I and then right here too what did I do I used I as a bite I already said it as a BT again so the problem is why do we have two I variables are unique they're supposed to be unique that's what Arduino is telling me so let me again set I maybe to let me call it counter because we're going to be using it to count so counter seems like a good name let me go right here and set every ey to counter okay there we go and let's check it out now all right can you see it it turns on for like a bit while we can see it visibly and then it fully turns off so let's see what's going on here okay so what's going on here is it reads the counter and then again runs through this code 300 times so basically drill screens a 300 times so it gives us enough time to what to see it obviously we can see it but afterwards what happens counter keeps adding up to 300 once it reaches 300 what happens again what happens once it reaches 300 H what happens is basically counter let's print counter at the end so let's see what counter is going to be at the end so let me go to serial.print Ln and let me just say counter at the very end because I want to see what counter is going to be up to all right I think this is good now what are we going to do uh obviously we have to what we have to start our serial monitor let me just do that let go to my setup code right here at the very end start our serial monitor at the bot rate of 9,600 give it a semic colum at the end and let's run this let's upload it right now it's done compiling and it should be uploading by now all right now let's open our seral Monitor and it's finally going to open it for us all right come on 301 can you see it the value that's coming out here saying what 301 301 printing out 301 so what happens is what 301 is what less than or equal to 300 so what it's not going to run this code another time can you see that it's going to be what it's going to be counter 300 what's going to happen is when it reaches 300 when it reaches 300 here okay let's go right here when counter is set to 300 this is going to be true and then what is it going to do it's going to draw screen a as usual and then it's going to be counter is equals to 300 + 1 what is that going to be it's going to be setting it to 301 now when it comes back and tries to do the loop again 301 is less than or equal to 300 that's a what that's a false statement so it's going to be skipping this at all it's not going to touch it again anymore and then what's going to happen is what it's going to keep printing the counter right now it's the value of the counter 301 okay all right so right here it's very important at the very end of the code that we what the very end of the code we set it to what we set the counter back to what back to zero to to its initial value okay we only printed a so what what's better is let's create a loop again counter is less than or equal to what what are we going to put right here as soon as it passes through 300 the value is going to be what 301 so I want it to be less than or equal to 600 right here that makes more sense to do then I want to do basically the same thing cross screen draw screen what for me R I wanted to draw screen R and then I wanted to counter to keep adding up again so that it's not stuck in a what an infinite loop I don't want it to be stuck in an infinite Loop what it keeps running R again infinite amount of time because it's always going to be true in that case as long as we don't add what counter is equals to counter plus what okay and then finally what we want to do we want to set it back to zero okay as soon as it runs through this what is going to be the value as soon as it's done running through this Loop the counter is going to be what 600 as soon as let's say it goes 600 right now it's going to be what 600 is less than or equal to 600 it's going to be true it's going to be drawing R and then six what the counter is going to be set to 600 + 1 what is 600 + 1 it's going to be set to 601 so again we want to set it back to zero so that loop again keeps going on so let's check it out there's an it should be an A and then an R it should be going between A and R there we go it's going between A and R A there we go and then it's going going to R nice now let's keep adding on again the other uh letters for Arduino we need D so let me just keep on copying this is better that way let me copy the white Loop ones let me the counters equal to zero at the very end so I don't touch it paste it and then now I'm going to go to 900 and now I'm going to go for what for our uh there we go D say capital D and the counter counter plus one I'm not going to touch that and then and keep on pasting this code just keep on pasting it it was 900 let me add 300 on 900 it be 1,200 and then I want to draw screen what after d i want to draw u u okay there we go seems nice let me paste that again and 1,00 it's going to be 1,500 do we then I have an i for the Arduino and paste that again um 1,500 and add 300 on it it's going to be 1,800 and then it's going to be are we okay come on there we go I hate the documentation sometimes can't touch it by using your pointer anyways and and then and then we have an O Arduino okay I to said this to what value 1,00 not 1,00 actually 2,100 there we go let's let's check what happens and we have again it's going to set this back to zero at the end that's good now should we just playing Arduino there we go and there you have it obviously uh one thing I want you guys to keep in mind is just going to keep doing it on Loop that's ni but one thing I want you guys to keep in mind is uh again this is what we're not using time directly we're not using delay time we're not using any type of what time we're indirectly using what what I want you to analyze is one thing we're using is what we're using ardino processing speed okay again it's going to be running through this code how many times 300 times so let's say we have a very very fast arbino mine is an Arduino Nano let's say we have a faster Arduino I'm talking a significantly faster one it's going to be running through this code really really fast so basically it's going to feel like how we just saw it for like again a bip and then it turns off okay so that's what's going to happen so again it's going to be very inal with on the adrenal model have and how fast it is okay so I want you to again adjust it using what as it's slower or faster I want you to adjust it for what for the number right here how do we make this way EAS easier then for ourselves give it a variable right it's better to give it a what a variable what I'm going to need to do right here is say Okay delay time I'm saying delay time right here you know what I can use this because I'm no longer using delay time here so I'm going to be setting delay time and what I'm going to be doing is I want to set it to 300 you know what let me set it to 200 because I feel like 300 is very long let me just set this 200 and again what I'm going to be doing is okay delayed I'm going to say delay time right here nice then I'm going to be saying delay time times what times two that's basically what it is delay time times three again this was again I just set it to 200 right now because I want it to go shorter okay that's what I wanted to do but obviously let me set it back to 300 so you can understand it delay time times uh it's delay time is what 300 and delay time * 200 is what 600 there we go that we put earlier 600 right here and then delay time * 3 is what 900 we literally put 900 right here delay time * 4 is literally 12 what 1200 okay so it's 1,200 so that's what I'm going to keep on doing so it's just times you can again use a variable instead of because we're going to be using this in multiple places it's going to be easier to do what it's going to be easier to use a variable so that again if you want to change anything we can change it only at one place and it's going to affect the whole thing let me see delay time times s right here and then we have delay time times eight there we go and we set the counter to zero and one thing I want to do right now is I want to set the delay time right here to what to 200 so that it goes faster okay I don't want to throw in the code 300 times I want it to go 200 times let's see if it goes faster now okay there we go it's better right now it's better or do we could the use a bit longer and oh there we go let's see set it to faster you know what let me just set this to 50 set it to 500 sorry 50 there we go let's upload it let's see what happens now there we go now it goes really fast r no there we go nice so again one thing I want you guys to keep in mind is we're not using delay time directly we're using what we're relying on our processing speed okay we're relying on arduino's processing speed we're just saying that you know take 50 it's going to take a long time right here so that we can see it so we can see what we can see a being drawn but let's say arduinos again like every computer like every what phone from here to here they get what they get faster they get better they get upgraded and all so maybe this might take again a while to write down for now for this model of Arduino but in the very future what's going to happen it's going to be so fast then it's going to be running it so so fast for example right here it's going to be almost as if you're running it uh giving it the delay time of let's say 5 milliseconds okay that's how fast it's going to be it's going to be like running this at 5 milliseconds because again the processing speed is going to improve it's going to be basically like that see that it's going to be so fast that obviously right now we cannot read this because again it's very very fast for us okay so that's one thing I want you guys to keep in mind so for example let's say we're using this for uh let's say producing something okay we're using this for production or something for a production basis obviously it's not going to be reliable it's not future proof because as I said again it's going to be running to problems but obviously this is just again a home project so it doesn't really matter that much but again I just want you guys to keep that in mind okay so anyways with that in mind let's finish this section well there you have it you've completed this sardino course and I hope you've enjoyed the journey as much as I have Before We Say Goodbye remember that finishing this course is just the beginning of your arino adventure the world of uino is fast and there are countless number of components projects and problems waiting for you to be solved with the skills you've gained here if you find this video helpful and inspiring please consider giving it a thumbs up that's a way of boosting the content so it can reach more learners like you and don't forget to subscribe to free Cod Camp to join a community of fellow programming enthusiasts plus it really helps the YouTube algorithm with that in mind if you want to check more courses made by me you can check my personal channel in the link below I don't want to keep you for too long thank you for tuning in and I hope to see you again soon