Arduino Uno R4 WiFi LESSON 16: Understanding If Statements and Conditionals

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello guys this is Paul mcarter with toptechboy dcom and we're here today with Episode number 16 in our incredible new tutorial Series where you're learning how to think like an engineer using the Arduino Uno R4 WiFi what I will need you to do is pour yourself a nice tall glass of ice cold coffee that would be straight up black coffee poured over ice no sugar no sweeteners none needed and as you're pouring your coffee as always I want to give a shout out to our friends over at sunfounder sunfounder is actually sponsoring this most excellent series of video lessons and in this class we will be using the sunfounder elite Explorer kit hopefully most of you guys already have your gear but if you don't look down in the description there is a link over to Amazon you can hop on over there and pick a kit up and believe me your life and my life are going to be a whole lot easier if we are working on identical Hardware but enough of this Shameless self-promotion let's jump in and talk talk about what I am going to teach you today and what I'm going to do is I'm going to teach you a new programming technique a new programming method that allows us to execute a certain set of code only if certain conditions are met okay now these are called if statements and inside the if statements are conditionals and those conditionals are the conditions which must exist for the code to be executed that is part of that if statement now that's just an introduction I'll really go into it so don't get uh don't get upset if that just went right by you but if you think of what we've done so far in this class all of our code has just executed over and over and over so like let's say we read a value from the potentiometer and we apply a value to the LED we read apply read apply read apply it does the same Snippets of code over and over and over or we ask the user for input and then we print the input we ask the user for input print the input it just does the same thing over and over but if you think of where we're going in this class imagine that we were controlling a fan you wouldn't want to just sit there and turn the fan on on on on on you would want to turn the fan on if certain conditions existed so let's say that we're measuring temperature so we would measure cond uh temperature and then we could say if the temperature is greater than 100° F then what you would do is turn on the fan okay and then if the temperature is less than 90° you would go ahead and turn the fan off and so if you were sitting there and the temperature was 95 nothing would change it would just read the temperature it's not greater than 100 it's not less than 90 it would just read the temperature read the temperature read the temperature but then when the temperature got above a 100 then it would execute the code to turn the fan on and the fan would stay on until the condition the temperature was less than 90 and then a command would be issued to turn the fan off so we want certain things to happen only if certain condition exist and that's what we're going to talk about today so what I'm going to need to do is get out of your way come over to the code view have a little sip of my Go Juice my jet fuel yeah I got my jet fuel what we're going to do is we're going to open up bare minimum so you're going to come to file you're going to say examples and you're going to go to Basics and you're going to open up bare minimum I always like to check and make sure that my Arduino is connected you can see on Port com by that it says the Arduino Uno R4 Wi-Fi is there that's good and then I also like to come down and I like to look at the uh board manager and see that the Arduino Uno R4 board is selected and the Wi-Fi version is selected so sometimes for some reason these things can get off so I always just like to check those when I get started okay so what I want to do is let's just write a simple little program that gets a number from the user okay and then if that number is positive the user is notified that they've entered a positive number if the ne if the number is negative then the user is notified that they have entered a negative number so what am I going to need well I'm going to need an integer so I'm going to go ahead and set that up integer integer my num like that I'm not going to give it a value because we're going to get that from the user okay I'm going to uh need another one let's say I'm going to have my prompt so I'm going to say a string and I'm going to say my prompt like that and I'll get that from the user too so or no I'm going to set that because that's a string that says please enter your number like that okay who is your friend Mr semicolon okay so let's see I'm going to read the number and then I am going to uh give a prompt and then I'll get the number from the user all right well we're going to come here and we are using that serial monitor so what do we need to do we need to do a serial. begin 9600 no no no no no no no we use variabl so we'll come up here and we will make that b rate an INT so I'm going to say int and it will be bod rate and that is going to be equal to 9600 okay like to put in my variables at at the top of the program I'm going to serial. at what at the B rate then I'm going to need my I'm going to need my semicolon now we come down to the void Loop and what do I want I want input from the user how do I get input from the user I ask I wait and I read so I'm going to ask serial.print Ln and please no no no no what do we do we come up here what what was it it was my prompt so we're going to print we're going to print l in we're going to print Ln and what are we going to print we are going to print my promp like that okay don't forget the semicolon and then now we have asked now what do we do we wait we wait in a while loop and while what condition is true while serial. aailable open close while that equal equals zero while there is no data on the serial Port while serial dot available is nothing there what do we do well we create our claw so I have the open curly to create my wild clause and then it put in for me the Clos curly I like to hit return and then what you can see is this curly closes the while clause and this curly closes the void setup Clause all right so as we're nesting these Clauses we have to make sure that we're balancing those opens open and Clos curries correctly okay we asked we waited now what do we do we read and what was that my num so my num is going to be equal to serial. parse we made it an INT so it's parse int and then like that so I'm going to read it now that was not good that was a colon now what do I want to do well if the number is positive I want to tell the user the number is positive if the number is negative I want to tell the user that their number is negative okay so what do I do I do an if statement if and then I put a conditional and the conditional is inside of parentheses so if and then my conditional which is inside of parentheses and then I'll put my condition in in a minute but just like a while loop I create a clause so I create an open curly and then you see it gives me the closed curly so this opens the if Clause this closes it and then I'm going to click enter okay now what we have to see is everything if this condition is true all the code between the curries between between this Clause the open curly and the closed curly all that code is going to be executed and after each step is done then it will drop out and it'll go past that Curly and then it will do whatever it's going to do next now I do not like do you see what I have a problem now look what happened here this curly is the if statement this ends the if statement well this one does what that ends the while loop but I wasn't supposed to do anything inside the while loop I was just supposed to sit and wait so somehow I put my if statement inside of the while loop that's wrong so what do I do I take that out and now this is good I open my if Clause I close my if clause and then this closes my void Loop this opens my void Loop what's wrong I never closed my wild Claws and I don't want to to do anything in it so I just come here and I close it so it just sits in Loops there waiting for data and doesn't do anything okay so if this condition is true all the code between the curlies is going to be executed well what do I want well if my num is greater than zero if my num is greater than zero then what do I want to do serial Dot print Ln and I'll say your number is pos positive partner okay remember how John Wayne was always saying what you doing partner so we'll use the partner word there and then okay so if my num is greater than zero then it's going to print out your number is positive partner okay now what if the other case what is the other case well if and then you see I closed it so I open the if Clause I close the if Clause now we're going to go to the next if Clause if my num and what do I do I need to put that conditional inside the parentheses so if my num is less than Z if my num is less than zero then what do I need to do I need to open my clause and then you see it closed it for me and then I'm going come down and and enter so let's just do a little bookkeeping this is opening the first if statement closing the first if statement opening the second if statement closing the second if statement and then this curly is closing the the the the void Loop so it really looks like I kind of got all of my curlies balanced out and nested properly well if my num is less than zero what am I am I going to do I am going to say serial. print Ln and then I am going to say your number is Nega neg negative partner like that and then we're going to come here and end it with a semicolon okay so it's going to ask me for a number I'm going to I'm going to enter the number and then it's going to tell me whether it's positive or negative so let's see if that works and man I've got a little bit of a problem here with this this window and I want to make sure that you can see it and I think that's going to be just dandy like that I think you can see it okay let's run the program and we hope we don't see any of that ugly little orange business I don't see any orange and now it is downloading and then we're going to get this out of the way and then why did it not give me a message because it printed it before I got the serial monitor turned on so I will just come and rerun the program by pressing that but button okay please enter your number my number is 10 okay your number is positive partner now please enter your number well minus 177 okay your number is negative partner okay so what the program does depends on a condition it depends on the condition of that number I entered how does that sound that sounds pretty darn good so I know if it's positive or I know it's negative now if you're thinking like an engineer you really got to think have I really covered all possible parameter Spaces by having positive and negative numbers okay what special case am am I not thinking of zero okay so what if the number is zero well if I just put zero in there it just asks me for another number but it doesn't give me any context of uh you know it doesn't give me any context of what it did with that number so what do I need to do up here I need to put another condition okay so I'm going to go after that close of that second one I'm going to say if where we going to say my num and then we're going to say if my num equals zero all right and then I'm going to open my Clause open my curly and then I'm going to come here and then I would say serial.println what would we say in this case we could say the number is neither positive or negative you know there's actually people that argue about whether zero is a positive or A negative number but we don't want to open that can of worms and so let's just say let's not let's not take a stand on it let's just say your your number is zero like that okay put a period and then we're going to put our semicolon and let's check again our curries I've got the open the Clause I've got the close the clause and then I've got this okay so now we're going to run it looks happy none of that ugly little orange nonsense okay please enter your number let's say five positive minus 5 negative okay now let's put zero enter your number we have a problem what is the problem I'll tell you what the problem is and the reason I do this is because you do it right this and this is actually like one of the hardest problems to find because when you look at your code it looks so perfect it looks so perfect but you made a mistake and you got to remember this because if you don't do Arduino a while and and then come back to this you're going to make this mistake again if I say if my num equals zero when Arduino gets there all it sees is inside of their my num is zero okay I'll make my num zero it sets it to zero what do you want to do you want to check if it's zero so you don't say if my num equals zero what you say is if my num equal equals z and you guys saw this before right when we were doing the serial do available in that pile Loop when we ask we wait and we read what did we do on a conditional do we have one up here I can't didn't we uh my PR yes serial. available so you see this is the condition that keeps the while loop running and what did we do it's like serial do available equal equal so if we're using in a condition for equal we've got to do the equal equal and that's in while Loops that's in uh if statements as well so if my num equal equals 0 then we're going to print your number as zero so let's download that again remember that equal equal on conditionals okay so let's put a number in let's say five all right your number is positive minus5 your number is negative and put in zero your number is zero boom you see it work Works remember it's equal equal now also let's say I want to know if I have a big number and I'm going to say a big number is more than 10 now you've got to listen to me carefully a big number is more than 10 so what I'm going to do is I'm going to enter my number just like I did here and then I'm going to say if my number if my numb is greater than 10 then what I'm going to say is your number is a big number okay now I'm going to say if my num is less than 10 then I'm going to say your number is your number is a small number small number like that okay so let's run this okay so enter your number well let's say I put 23 23 is bigger than 10 so that is a big number what if I put seven 7 is less than 10 10 and so it is a small number now what have I not handled very well what have I not handled very well I haven't handled 10 very well because I didn't give it conditions for what to do when it's 10 and man guys this believe me I can't tell you how important this is and in real world engineering applications the errors the catastrophes always happen at these boundaries between one region and another region and so what is our region greater than 10 what is our region less than 10 what is the boundary it's 10 itself and you've got to be deliberate to explicitly mindfully skillfully handle those boundary conditions all right now I want I want you to think what did I say it is a big number if it is what what did I say it is a big number if it is more more than 10 if it's more than 10 it's a big number so this is good if it's greater than 10 it is a big number if it's less than 10 it's a small number but what if it is 10 okay what if it is 10 well that's a small number because 10 is not more than 10 so you could think well I could add another if statement that says well if my num equal 10 no if my num equal equal 10 then I would also print your number is small but what I want you to see is there are other conditions I could come in and I could say if my numb is greater than 10 and then this one would be if my num is less than or equal to okay and then if it's less than it'll go into this if statement if it's equal to it will go into this if statement so you see I've tightened up that boundary I have tightened up that boundary so let's run it okay so let's come in and say what is your number my number is 11 11 is uh your number is a big number what if I said nine your number is a small number and what if I said 10 10 is a small number because it's not more than 10 it's not more than 10 okay so that is pretty slick so what do we know we know greater than we know less than we know greater than or equal to you can also Imagine or we know less than or equal to and you can also imagine that there is a greater than or or there is a greater than or equal to less than or equal to greater than or equal to equal equal and less than and greater than so those are the things that we've learned so far so let's see let's see what if there's another one like what if we just want to tell someone that the number is not zero okay I want to know if the number is not zero so what would I do in that CL in that case I would say if and then I would say my I got to get rid of this other stuff here I got too much stuff there okay if my num okay if my num equal equal Z no I don't want to know if it's equal to zero I want to know if the number is not zero okay I want to know if the number is not zero the good news is we have a symbol for not and and that is your old friend Mr exclamation point so this is saying if my numb is not equal to ah that was very very bad I moved it I was trying to highlight it and it moved it so if my num is not equal to zero then what do we want to do we want to come in and we want to say serial. print Ln and what we're going to print your number is not zero like that and then and then then this curly closes that if Clause then just for good measure I I can then say if my num equal equals zero then what could we say we could say serial.print Ln we could say your number is indeed zero like that always like to check for balance okay oh look at that what happened what did I do you see it looks like maybe this if statement is inside of this if statement because I didn't what I didn't close that so after I do the print I need to what I need to close the curly now this one I'm opening the curly I am closing the curly and then this curly closes the void Loop okay so now let's try [Music] this okay what is your number my number is 237 your number is not zero if I type in zero your number is indeed zero boom we've got our if statements going okay so let's uh let's try a different one let's say if our number is even or odd and I I kind of want to show you just different commands and get you used to different commands and so what I'm going to do is I'm going to add a another integer and the integer is going to called remainder r m for remainder and then I'm going to calculate that so I'm not going to put I'm not going to put it in so what do I want to know I want to know if your number is even or odd how could we figure out if a number is even or odd well we're going to come down here we're going to come down here and then I'm going to ask I'm going to wait I'm going to read read and then I'm going to get rid of this other stuff so I ask weight read and then I'm going to say my remainder my remainder is equal to what am I going to take my num and then mod two okay what does the modulus do the mod divides the number what is this going to do it's going to take my num and it is going to divide by two but it's not going to give me the div it's not going to give me the answer it's going to give me the remainder so what is five mod 2 well 5 / two would be two with a remainder of one so if I put 5 mod 2 if my numb was five remainder would be one if my numb was four 4 / two is two no remainder and so there the r the remainder would be zero okay so four mod 2 is zero because there's no remainder so if the remainder for my num mod two if the remainder is one the number is odd the number is odd if the if the rim if the manum mod two is one the number is odd if the minum mod two is zero then the number is even okay how cool is that all right so now let's do that so I'll say if if put in my condition if Rim equal equal one then what equal equal right if Rim equal equal one then serial. print Ln print Ln and then what am I going to print your n your num number is odd okay like that okay and then this time I was good to close out that curly like I should and then what am I going to say if the remainder equal equal Z and what am I going to say I'm going to say serial.print Ln and say your number is even like that let's try [Music] that what happened what happened to me ah who's your friend Mr semicolon okay let's look at this none of that orange ugliness we've got the download going and we got the download going there it is now we're going to come over to the serial monitor it's asking me for my number and so let's say I put 13 okay your number is odd what if I say four okay your number is even what if I say uh what if I say minus 6 minus 6 your number is even what if I say minus5 your number is odd okay what did that do that number is even wait a minute let's see minus 5 what is going on here so let's print remainder so we have an unexpected Behavior here we have an unexpected Behavior here if Rim is equal equal zero so let's print uh Rim out so let's say serial.print Ln and let's just go ahead and print r m so we can see what it is see I'm helping you debug I'm helping you troubleshoot because we're getting an unexpected behavior for some reason that is not going into the odd one here that is not going into the odd one for negative number so let's see what happens let's see if we can figure out what happens there by doing a selective print okay so now what I'm going to say is I'm going to say three your number is odd and the remainder was one that makes sense two the remainder is zero your number is even what if I said minus 6 it says the remainder is zero your number is even what if I say minus5 ah look at that the remainder is minus one so it's reporting the remainder for negative numbers as a negative number and so what can I do with that well I want it to be if it's one or negative one if there's a remainder H how could I do that I could say if the remainder instead of equal one I could say if the remainder is what not equal to zero now let's see if it works so not equal or equal equal okay so now let's do a three three is odd two 2 is even Min - 6 - 6 is even and then minus5 number is odd okay so that's really really good so another way we could do it we could say if the remainder is not equal to zero or what if we said if the remainder how about if we took the absolute value of the remainder so I hate doing this on the fly but I think it's like Abs if the absolute value of the remainder if the absolute value of the remainder equal equal one that would take the minus one and it would turn it into a one and so it makes all the absolute value function makes everything positive so let's see if that would also be a way of doing it at least it's running at least it's running and it's downloading and let's try that now okay let's try that what I'm going to say is minus 4 your number is even minus 2 your number is even minus three and your number is odd boom so I showed you two different ways to get that negative one now really I did this for a purpose and that is you've got to check your code and this is the biggest mistake that programmers make even salty professional tried and true programmers the problem is they don't check their code carefully enough because if we checked it for 2 3 4 5 it works and we think great but what didn't work for negative number so you've really got to pound that code and you got to check it for all possible conditions what's one thing I haven't checked it for haven't checked it for zero okay and if I put in zero it says your number is even now people will probably argue whether zero is an even number or not but if I divide Zero by two I don't get a remainder so I'm going to go with it being even okay I'm going to go with that now this is the other thing that you have to think about sometimes you want more than just one condition sometimes you want more than just one condition in that case you want compound conditionals so I'm going to give you a number and I want you to tell me it's odd it's odd and positive it's even and positive it's odd and negative it's even and negative all of those different things so how would we do compound conditionals okay well what I'm going to do here is I'm going to go ahead and keep my remainder but then I'm just going to do these things again okay so now what am I going to say I'm going to say if if if the my num is is greater than if my num is greater than 0 and now and how would I tell it I want two conditions this one has to be true and this one has to be true if my num is greater than zero I put the double and and and if my num is greater than zero and and remainder remainder equal equal Z if both of those things are true if both of those things are true then what do I want to do serial. print Ln and then what am I going to print Ln you have a positive even number like that better put my quotes there better come here here okay and now I put my call I'm going to check this because I have a tiny little concern whether there's might be a different way that this needs to be done I want to make sure that I've got the compound and working right okay so it wants my number and so I'm going to say four and if I say four it says you have a positive even number so yeah that worked right okay so now what I'm going to do is I'm just going to copy this okay and then I'm going to come here and I'm going to paste it but this time if my num is less than zero if my num oh that was crazy business there if my num is less than zero and the remainder is zero you have a if my num is less than zero you have a negative even number how about that okay now there's two other cases that I need to do and I think what I can do is I can just paste that last one again so I'm going to paste it again and so I've done greater than zero less than zero even now I'm do greater than zero and uh with a remainder in that case I have a positive odd number okay and now I'm going to do one more and that is if my num is ah I should paste that why didn't I paste that okay so that's one two three four that's all right so now this last one is if my num is less than zero man that is really it's trying to finish those brackets for me if my num is less than zero and and the remainder is one less than zero you have a negative and it is odd okay you see guys I can have more than one condition up here for you to fall into this if statement two things have to be true my num has to be less than zero and and remainder has to be equal equal one okay so now let's try this what do you think is that good I think that's looking pretty good okay so now that is there so we're going to come up here and we're going to say three and let's see what happens it says three you have a positive odd number good four four you have a positive even number minus 4 you have a negative even number minus5 ah what happened we forgot down here right we made the same mistake that we made before and that is if it's less than zero I need to take the absolute value of the remainder so that if it's a negative remainder it'll make it a positive uh it'll make make it a positive uh remainder so now let's try that okay sometimes I make the mistakes on purpose and sometimes it's just a mistake you never know for sure do you sometimes I don't deliberately make a mistake but I tend to be a little sloppy when I'm making these classes because I kind of want problems to come up and then I want you to see how I troubleshoot them so I kind of like the problems popping up because one of the most important things I want you to learn in this class is how to troubleshoot your code okay how to troubleshoot your code so now we're going to go three you have a positive odd number for where did that go positive even number minus two you have a negative even number minus three and negative odd boom we got it okay we got it now I would let you go in and handle the zero case like if it's a zero case you could just add another if statement just if it's zero it's zero just call it zero don't argue about positive negative odd even or whatever you could just you could do it that way okay so we've done all that let's try something else let's ask it for a color okay let's ask it for a color and if the color is red you want to print Red Alert if the color is not red you want to just print the color okay so what am I going to need I'm going to need a new string I'm going to need a new string variable and that new string variable and I do not need now this RM I don't need this numb and here on my prompt instead of please enter your number please enter your color okay please enter your color and I'm looking for something right here if you'll give me just a second give me just a second okay this will this will do it all right so now what I want to do is I'm going to prompt I'm going to ask I'm going to wait and I'm going to read but instead of here my prompt what I'm going to need is a string my color and I'm not going to give it a value because I'm going to read that okay I'm going to read that in so then here we come down here and then I ask I wait and I read but this time I am reading what I am reading my color okay my color and then that is going to be serial. what read string because it's going to be a string and guys remember it's got to be no line ending when you're doing these inputs from the serial monitor you have to have the things set at no at no line ending or you're going to get very unexpected results so now let's take out all these if statements let's take out all of these if statements okay and so I read it and now what do I want to do I'm going to say if my color got to put it in the old parentheses if my color equal equal what if it equal equal the string what red then what I am going to do is if that's the case open curly close curly I'm inside the curlies I'm going to do a serial. print Ln and then what I'm going to print is Red Alert Red Alert like that put some exclamation points in there okay now what am I going to do what am I going to do if if my color is not equal to Red if it's not equal to Red then I am going to come in open my Clause open curly close curly and I I am going to do a serial. print what am I going to print your color is leave a space come over semicolon and now serial.print l in and then what am I going to print my color so I just report back the color if it's red I'll give a red alert okay so now let's put this here okay now I'm going to come here run it man I'm getting low on coffee little bit of a long lesson but I didn't want to I didn't want to break this into two I think all this stuff really goes well together so okay so now let me hit this button again please enter your color okay my color is red says your color is red I didn't get my red alert I didn't get my red alert somebody tell me why I didn't get my red alert I said if my color is red I I oh oh oh oh oh look at that okay no no it says if my color is not equal to Red it prints your color is that but if my color is equal equal red it should have given me one what it should give me my red alert I didn't get my red alert somebody tell me why I didn't get my red alert in Arduino and most programming languages case matters so what did I do I tested on red I tested on red but I didn't test on uppercase r d okay so uppercase our little Ed so what could I do well this would not be an and this would be a what an or so if my color is red lowercase or if my color is red uppercase so how do I do an or well you look on your keyboard usually it's above the enter key and it's above that slash but it is that vertical bar and on mine above the enter key on the keyboard there is a slash and then there is the shift slash makes that vertical how do I do an or an or is SL SL bar bar I guess we'll call it or my color equal equal red like that in either one of those cases we're going to get a red alert does that sound good okay let's come up here let's run [Music] this okay so now what is your color if I say green it says uh your color is green that makes sense if I say green says your color Isen screen that makes sense if I say red Red Alert boom got it but now what if I say red like that red alert that works red little that works how about uppercase r no red alert okay now you see the reason I did this I wanted to show you how you could do a compound conditional with an R with an or we did compound conditionals with an and and here I did compound conditionals with an or you go into the if statement and an or if either of the conditions are true if either condition is true you go in if it's and you only go in if both conditions are true okay you only go in if both conditions are true so or either one and has to be both okay so you could see that we could come in and we could put like 20 different or state or statements like uppercase R little e uppercase D so that is just really kind of that is just kind of uh that is just sort of a a mess there so so I'm going to show you really the way you do this the the the way that you would do this would be uh like this we're going to read we're going to read my color and then what we are going to do is we are going to say my color and then what we are going to do is to lower case like that so now that's going to take my color and it is going to change it into it is going to change it into all lower case and that way it's always just taken the case out of it so if it was uppercase r d it would make it lowercase red and in that case I don't need this R and I am very frightened that if I'm really doing this right okay didn't seem to crash what I wasn't sure is I wasn't sure if I needed to say my color is equal to my color. lowercase okay but let's try this let's try green like that it's happy with green let's try red boom I got a red alert even though even though I entered even though I entered an uppercase even though I entered an uppercase so watch me carefully this time now watch this uppercase R little e uppercase D and that is going to convert that that's going to convert that to all lowercase and then all I have to do is compare it against lowercase r e d how is that that's pretty good that worked right and so let's uh let's see let me hit enter okay red alerts you see that was working that was working okay guys what have we learned we've learned greater than less than greater than or equal to less than or equal to we've learned equal equal we've learned not equal we've learned convert something to lowercase to make it easy here to compare strings we've learned that you have to do the no line ending and we've learned that we can do these logical operators these conditionals on strings just like we can on numbers all right just like we can on numbers and the very important thing we learned is the very important thing that we learned is you've always got to cover those boundaries so like if you're going to go in temperature ranges of 0 to 100° and want to do something different at every 10 degree increment you've got to make sure that you're watching those boundaries between at 10 what are you going to do is 10 going to be part of 1 to 10 or is 10 going to be part of 10 to 20 it needs to be in exactly one either you go one to 10 and then anything above 10 goes from there to 20 and anything above there goes to 30 you see you've got to decide what you're going to do with those boundaries and be consistent and we'll probably go over this more in some future lessons but let's see what I need you to do is I'm going to give you a homework assignment and what that homework assignment is is to get out your Deluxe little bag of LEDs get out your little Deluxe bag of LEDs get a red one a green one and a yellow one I guess I should say red yellow green and hook up three LEDs and then what I want you to do is I want you to ask the user which led they want to turn on and whichever LED is selected you turn that led on okay and so it's going to be a user selects the LED to turn on and this will get us back a little bit more you see we kind of got the naked Arduino here without anything hooked up to it and what we want is we want to get back in and sort of start building a circuit so a red a green and a yellow and remember remember no blue blue is for special occasions so don't use those blue LEDs we're going to save those for some really special occasion so that is your homework assignment okay guys I hope you're having as much fun taking this class as I am making it as always I want to give a great big thank you to you guys who are supporting me on patreon it is your support and encouragement that keeps this great content coming you guys can also help me by giving me a thumbs up and leaving a comment down below if you haven't already subscribe to the channel when you do make sure you ring that Bell so you'll get notifications When Future lessons drop and most importantly share this video with other people because the world needs more people thinking like an engineer and fewer people sitting around watching silly cat videos Paul mcarter with toptechboy tocom I will talk to you guys later
Info
Channel: Paul McWhorter
Views: 2,981
Rating: undefined out of 5
Keywords: STEM, LiveStream, TopTechBoy
Id: H5OlCuUWEg8
Channel Id: undefined
Length: 53min 24sec (3204 seconds)
Published: Thu May 09 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.