So my dad ordered me an andruino kit and it's going to arrive in around two weeks. Before it arrives I want to become familiar with the language, so here's a simple script i made for two LEDs to flash alternaltely like this (0,0,,1,1[repeat])
Here is the code i put together:
Would that work? If yes, then I have another question. Would it be possible to put loops inside the main loop to make the code shorter?
Yes, it would work. Yes, you can add for loops and while loops to the loop() function.
I tried doing that, but I got really confused. Can I set a number for how many times the loop will repeat before it ends?
Can you make two loops inside a loop that execute one after another?
When i try to do that I end up with the two loops looping simultaneously, is there a way to pause one loop to give the other one time to complete a given number of loops?
Can I set a number for how many times the loop will repeat before it ends?
You need to be clear whether you are referring to a for loop or the loop() function. The loop() function executes over and over, forever. The for loop iterates as many times as you tell it to:
for(int i=0; i<someCount; i++)
{
}
will execute while i is less than someCount, incrementing i after each execution of the block of statements.
Can you make two loops inside a loop that execute one after another?
You can do almost anything, with the right code.
When i try to do that I end up with the two loops looping simultaneously
Physically impossible.
is there a way to pause one loop to give the other one time to complete a given number of loops?
Yes, and no. Really, it would be a lot easier to look at, answer questions about specific code. Any code, doesn't really matter. We are interested in seeing you learn to program.