SunFounder 3in1 Kit
(continued from previous page)
void loop() {
digitalWrite(13,HIGH);
delay(200);
digitalWrite(13,LOW);
delay(200);
}
Note: Use the shortcut Ctrl+/ to help you quickly comment or uncomment your code.
Commment /**/
Same as // for comments. This type of comment can be more than one line long, and once the compiler reads /*, it
ignores anything that follows until it encounters */.
Example 1:
/* Blink */
void setup() {
pinMode(13,OUTPUT);
}
void loop() {
/*
The following code will blink the onboard LED
You can modify the number in delay() to change the blinking frequency
*/
digitalWrite(13,HIGH);
delay(500);
digitalWrite(13,LOW);
delay(500);
}
#define
This is a useful C++ tool.
#define identifier token-string
The compiler automatically replaces identifier with token-string when it reads it, which is usually used for
constant definitions.
As an example, here is a sketch that uses define, which improves the readability of the code.
#define ONBOARD_LED 13
#define DELAY_TIME 500
void setup() {
pinMode(ONBOARD_LED,OUTPUT);
(continues on next page)
72 Chapter 2. Get Started with Arduino