HW for Paul McWhorter's Uno R4 WiFi Class Lesson 20

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] hi this is Lori and this is my homework for Paul mccarter's uh Uno R4 course this is for lesson 20 in this lesson we've been asked to redo the homework that we had in lesson 19 and um do it using a uh without using a for Loop and so we're flashing red green blue sequence uh and we're asking the user how many times they want to do that and allowing them allowing it to do that come back and ask again and so Paul asked us not to use a for Loop to try to come up with another way of doing that homework and uh so um pretty sure he's uh pushing us to uh try a while loop but I thought about it for a little bit and thought wouldn't it be interesting if we didn't use a for Loop and we didn't use a while loop to to make this homework happen so that was a little challenge I made for myself to see if I could do the homework without using a four or a while loop and so that's what I did all right so here's the code that I put together um to do this and um the the basic idea and I ran into this when I did some projects on my project Channel where I was um soldering my own Uno kit and doing some music uh uh programming with the Arduino and I learned from some folks who do a lot of that kind of programming and they often use the void Loop itself to do any looping they needed for some of these music uh applications and so it got me to thinking yeah I'm already looping with the void Loop can I take advantage of that Loop and not use any more looping structures um to make it happen so so that's where I kind of got that idea from so uh I took all the LED Matrix out just to kind of simplify it a little a little bit um so I'm still uh very similar to my lesson 19 homework I'm using numb Cycles that's what the user will get me how many how many flashes of red green blue they want um delay time and then I had to create a another variable called Boolean go to start and I set that off as true to start uh the same setup as we've had before and I'm still using my uh RGB LED function to light the uh light the RGB LED and and here's where the magic starts to happen in the void Loop um so I don't want to do all that asking uh of how many cycles you want you only want to do that when we finished um either at the very beginning or when we finished doing the number of Cycles uh that the user wanted so I have to set that aside so I'm using an if statement to say if go to start is true then we're going to go through this and ask the user for the number of Cycles um but if it's set to false then it'll skip this piece and it'll do the flashing so you can see once you go into this you're only going to go into it once because it it immediately sets it to false so you won't go back in here again unless something else changes it back to true all right so um this is all similar to what I had in the lesson 19 homework um so that just gets the number of cycles and makees sure that it's in a Range that we think is reasonable all right so um here if the number of Cycles gets to zero then I'm going to uh set go to start true so then we'll go back and ask the user again that means we finished doing the flashing um and then if it's greater than zero then I want to do a flash on this run through the loop and so that's all this code does here and then um once we finish that we'll subtract one from the number of cycles and this is probably what a lot of people did with the while loop as well um you know you subtract and and uh keep it going but as I said not using a while loop I'm just taking advantage of the fact that in this sorry for moving around so much but in this void loop we're actually looping and uh by making sure I set aside this this starting stuff um uh it should work all right so uh that's what I have uh plugged in here so let's uh let's clear the the uh the thing and we'll just restart it again again get our prompt back and then we'll just type in uh let's do three and we should see three and then it came back and asked us now if we ask for zero it's going to say well you didn't ask for enough Cycles so you get one and you saw one one cycle of it Flash and as I did before I'll just pick another number larger than 25 and it says hey you asked for too many and it sets it to 25 so uh yeah so you can Loop without doing a for or a while if you take advantage of the Void Loop itself well that's my homework uh thanks for the great lessons PA and thanks for making me think of trying to do this uh a different way that's always fun and thank you guys uh for watching [Music] he
Info
Channel: Lori's Homework
Views: 103
Rating: undefined out of 5
Keywords:
Id: YGJn0l68JHA
Channel Id: undefined
Length: 5min 33sec (333 seconds)
Published: Sat Jun 29 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.