OK, skip down and you'll find this section of code:
// the loop function runs over and over again forever
void loop() {
digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(13, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}
So good - so.... time for a Quick Quiz! (Don't worry, you wont be graded)
Quick Quiz #1!
What is this line of code:
// the loop function runs over and over again forever
(A) A statement
(B) A single line comment
(C) A function definition
(D) A bowl of cereal
Answer: B it is a single line comment (Click to reveal the answer!)
OK that was not so hard but hey, it's good practice! Also I'm getting a little hungry.
Now that you have passed the quiz lets skip the next line and....time for another Quick Quiz!
Quick Quiz #2!
What is this line of code:
void loop() {
(A) A statement
(B) A single line comment
(C) Part of a function definition
(D) A banana
Answer: C it is part of a function definition (Click to reveal the answer!)
If you didn't get that one right, now might be a good time to review the previous section! Orange you glad it wasn't a banana?
Another Function
You've had some practice with looking at the setup function. Now it seems we have encountered another, different function called loop. Like setup, this function returns nothing, a.k.a void, and has no inputs. The body of loop - the collection of statements - looks a bit different though:
{
digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(13, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}
The Legacy of loop()
You've already learned that the special function setup() determines what code is run when the Arduino first starts up. Not surprisingly, loop() is also special
Now's a good time for yet another quick quiz:
Quick Quiz #3!
How many statements are in the body of the loop() function?
Answer: There are 4 statements inside of the loop() function definition (Click to reveal the answer!)
Good work passing those quizzes. If you weren't sure about what each line of code was, or the number of lines in the function, now is an excellent time to review the previous sections
Once you feel comfortable and you know those answers without hesitation, lets delve deep into loop...
Text editor powered by tinymce.