This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
tutorials:learn:arduino:lesson2.html [2010/10/20 21:46] daigo |
tutorials:learn:arduino:lesson2.html [2016/01/28 18:05] (current) |
||
---|---|---|---|
Line 106: | Line 106: | ||
}</code> | }</code> | ||
- | OK we've got two comments, each starting with //. We understand comments already so lets skip that. \\ We also see in the middle there is a statement, we know its a statement because it ends with a **;** (semicolon) however there's a whole bunch more stuff before and after it. \\ This bunch of code is an example of a **procedure**, a procedure is a collection of statements, its used to group statements together so that we can refer to them all with one name. Its just like a procedure that we use to perform a task step by step. | + | OK we've got two comments, each starting with %%//%%. We understand comments already so lets skip that. \\ We also see in the middle there is a statement, we know its a statement because it ends with a **;** (semicolon) however there's a whole bunch more stuff before and after it. \\ This bunch of code is an example of a **procedure**, a procedure is a collection of statements, its used to group statements together so that we can refer to them all with one name. Its just like a procedure that we use to perform a task step by step. |
- | | + | |
- | ^**returned value **^**procedure name**^(input values) ^**{ statements } **^| | + | ^**returned value**^**procedure name**^(input values)^**{ statements }**| |
|void|setup|()|{ pinMode(ledPin, OUTPUT); }| | |void|setup|()|{ pinMode(ledPin, OUTPUT); }| | ||
Line 234: | Line 234: | ||
- | **Exercise 2. \\ Modify the code so that the light is on for 50 msec and off for 50 msec. What happens? ** \\ //Highlight the text below to see the answer // \\ Intense strobe action! | + | **Exercise 2. \\ Modify the code so that the light is on for 50 msec and off for 50 msec. What happens? ** \\ //Highlight the text below to see the answer // \\ <class white>Intense strobe action!</class> |
- | **Exercise 3.** ** \\ Modify the code so that the light is on for 10 ms and off for 10 ms. What happens?** \\ //Highlight the text below to see the answer // \\ The light is no longer blinking | + | **Exercise 3.** ** \\ Modify the code so that the light is on for 10 ms and off for 10 ms. What happens?** \\ //Highlight the text below to see the answer // \\ <class white>The light is no longer blinking</class> |
- | **Now pick up the Arduino and gently wave it back and forth, in a dark room. What happens?** \\ //Highlight the text below to see the answer // \\ The LED creates a dashed trail of light in the air. z | + | **Now pick up the Arduino and gently wave it back and forth, in a dark room. What happens?** \\ //Highlight the text below to see the answer // \\ <class white>The LED creates a dashed trail of light in the air.</class> |
- | **What do you think is happening here? \\ **//Highlight the text below to see the answer //** \\ **The LED is blinking, but its blinking so fast that our eyes can't pick it up, so it looks like a blur. When the Arduino is waved in the air, we see streaks of light from the blinks. | + | **What do you think is happening here? \\ **//Highlight the text below to see the answer //** \\ |
+ | <class white>The LED is blinking, but its blinking so fast that our eyes can't pick it up, so it looks like a blur. When the Arduino is waved in the air, we see streaks of light from the blinks.</class> | ||