Arduino Workshop - Chapter Three - FOR Loops
HTML-код
- Опубликовано: 6 мар 2017
- The full Arduino Workshop in step-by-step format can be found here core-electronics.com.au/tutor...
In this section, you'll look at 'for' loops which you can use to control the flow of your program.
We're official retailers for Arduino in Australia - powered by makers, for makers! core-electronics.com.au/ardui...
I’ve just discovered your channel and really like it, good job.
You explained very well
Thank you for posting this video, it has been a great help in my learning of Arduino coding. I would like to ask if I wanted to have this LED ramp 5 times would I add the first part of the code you show at min: 0:20 around the ramp code by using curly bracket? Thank you again for posting these videos.
nice lesson thank you ...
Thanks for explanation. I like it
As you only want to count 0-255 would you save memory if you defined i as a BYTE datatype rather than an INT?
Can I know how to loop forever the melody example in arduino??
I don't want to ramp up and down. Just want to blink the led 5 times. Stop. And wait for a Button push again. Any videos on that??
i had troble with this so i watched other videos and i found the error you must be plugged in with a digital pwd most bords have these and are marked with a ~
What does the statement "for(;;);" do? I've seen it in a couple of example sketches. Thanks.
thanks a lot.....
Thanks for sharing. I finally understood the for loop. Now I kinda feel dump for not being able to understand it sooner 🙃 😕
How do I make the code jump out of the 'for' loop? As soon as it counts to 5 for me, it starts over at 0 and jumps straight back into the loop. I want the value of x to stay at 5 until I press a button.
i believe you would add
break;
inside of the "for" loop. but im just referencing his previous video about "while" loops so i might not be correct. lol
In case someone else's LED only ramps down and not up, write "for(int i=0; i < 256; i++)" instead of the first _for_ shown in the video. Mine behaved like so and with that correction it now works properly. I'm guessing "int i" doesn´t declare AND set the variable to 0, so that's why it only ramped down. Someone correct me if im wrong
Yeah I'm pretty sure you're right. He had a typo for sure.
I think they chose i for for loops because it stands for iterations.
It stands for 𝑖, 𝑗 indexing Index Notation in math. [Aᵢ ⱼ] where 𝑖 - index, 𝑗 - is just the next letter for labeling the next dimension (then goes 𝑘, 𝑙, 𝑚, 𝑛 ...)
Nice. fyi, 'i' is used for convention in loops to indicate "iterations".
I'm trying to make a game where LED's blink back and forth and when you press a button it stops on the LED it's on and gives a certain point value for each LED but the for loop keeps iterating and blinking the LEDs
How do you do 7 led lampjes burning
I searched this on youtube for the same thing!!!
I've had to change "int i" for "int i = 0" in my first for loop otherwise each loop starts with i having a value of 255. i.e. if I don't add "int i = 0" the LED starts each loop at max brightness then fades instead of ramping up then fading.
i'm also facing the same issue right now. i want to know the reason why this is happening like sir. can you help me?
void setup()
{
Serial.begin(9600);
}
void loop()
{
int i;
for(i; i
Same thing happened to me. This fixed it.
same
I love you.
So a 'for' is like a sub loop?
It is. And this is why this code is "blocking" it halts the Loop until For is finished.
my brother told me i need a for loop for a buzzer tone sequence on an if but this video made no sense to me.
void setup()
{
Serial.begin(9600);
}
void loop()
{
int i;
for(i; i
tricky ! If you can, please post this to our forum coreelec.io/forum - our team can provide better support for coding issues there.
Its becaude the ASCII equivalent of 0is 52. You need to convert it to integer to see correctly in serial monitor
If this doesn't work for you then make sure you are using the digital pins (NOT analog).