ARDUINO Understanding While #Loop 10K Tech 101 Electronics (BASIC)

10 Просмотры
ARDUINO Understanding While Loop 10K Tech 101 Electronics (BASIC)
#arduino #electronics #LED
In today’s video We will learn all about the “WHILE LOOPS” and their fundamental part in programming.
They allow a section in the code to run continuously as long as the condition is true, and will break out of the loop when it is no longer true or when the function to breaks is called.
Now I do not want You to be confused as it may seams that the “WHILE LOOP” act like an “If STATEMENT”, You must agree in principle they do same, and that is to Look for a set of criteria’s but they are acting much more like a “FOR LOOP” that can run over and over and over and over again.
This is where You might get confused, as The “WHILE LOOP” is very similar to a “FOR LOOP” where You Put the word “WHILE” and only then put the condition within the brackets with this code entered within the following curly brackets, the difference is that We have to manually control the variables, and the iterations manage only the condition for Us. It is better if I'll show You what I mean.We will Use the same code to Show and explain their differences; this will be a great refresh for some of Us.
This “IF STATMENT” We have here does runs only one time, the reason why it often looks like it runs more than once in some of the codes is that We placed our “IF STATMENT” inside of a loop and so this if statement runs one time if it's true gets to the end of our loop and because this is a loop it cycles back around it does this “IF STATMENT” again You can (PAUSE) the video really quick to see if You know what's going to happen when I run this. So what's the first word You thought it is going to be printed You I am curious to kind of see what order You think it will be?
let's go ahead and run it really quick We know. I keep it this way on purpose to see We were right, it went really quick We saw some “TRUE” at the beginning now it is just the word “FALSE” We shouldn't leave it like to fix this a simple delay and We will be able to see what is happening. We can comment that out later when We know everything's working the way We want.That's better We can actually see stuff Now so it printed this ten times and then after that it printed “FALSE” over and over and over again. Click Here to stop the auto scroll and it will be easier to go back up.
Now let's figure out what would happen if We just change the “IF STATMENT” to a “WHILE LOOP” and think about it. the ”WHILE LOOP” We have to be specific, We not only need a way to get in HERE, We also need a way to get out HERE. and all We have to do is simply going to put Our out into Our ”WHILE LOOP” Now We have both the in and Out. We have a way to get in the right X equals 0 here that's what it's going to start out, and I'm going to be changing X within my ”WHILE LOOP” with this which means that after it runs 10 times We will be out and the word “FALSE” will run forever after that.
Now We have a clear difference between the “IF STATMENT” as We will not get “TRUE” , “FALSE” 10 times in row printed Before it only output , “FALSE” instead We will get , “TRUE” 10 times without and then “FALSE”, as we hop out here.Lastly to the “FOR LOOP expect something more specific. We have to put three conditions in here but for a “FOR LOOP” We basically drag this up to here but remember the three statement must be separated by a semicolon.
We test this and it should run exactly like our last “WHILE LOOP” .

Now let me know if You wish me to give You guys a challenge to solve with the answer on the next video?

Link to Sites:

If Statement (Conditional Statement):
if - Arduino Reference:

You guys can help me out over at PATREON: and that will keep this content coming:

Link to My Most Watched Video:

Recover You r lost data With DISK DRILL even with the free Version

I find the Best Calculator Ever & it is free.

How to Change from Microsoft Edge to Google Search Instead (UPDATED)

Link to the other CYBERPUNCK 2077 Video:

Feel Free to leave a comment, Please, or a remark maybe even a request or question in the comment section bellow may You have any, and, If You LIKE this video, please do HIT the SUSCRIBE Button and, OR, the bell Icon.

????Your 1 Subscription to My Channel Can Make My Day ????

THANKS a MILLION for YouR time
Комментариев нет.