SunFounder 3in1 Kit
(continued from previous page)
}
void loop() {
digitalWrite(ONBOARD_LED,HIGH);
delay(DELAY_TIME);
digitalWrite(ONBOARD_LED,LOW);
delay(DELAY_TIME);
}
To the compiler, it actually looks like this.
void setup() {
pinMode(13,OUTPUT);
}
void loop() {
digitalWrite(13,HIGH);
delay(500);
digitalWrite(13,LOW);
delay(500);
}
We can see that the identifier is replaced and does not exist inside the program. Therefore, there are several caveats
when using it.
1. A token-string can only be modified manually and cannot be converted into other values by arithmetic in the
program.
2. Avoid using symbols such as ;. For example.
#define ONBOARD_LED 13;
void setup() {
pinMode(ONBOARD_LED,OUTPUT);
}
void loop() {
digitalWrite(ONBOARD_LED,HIGH);
}
The compiler will recognize it as the following, which is what will be reported as an error.
void setup() {
pinMode(13;,OUTPUT);
}
void loop() {
digitalWrite(13;,HIGH);
}
Note: A naming convention for #define is to capitalize identifier to avoid confusion with variables.
2.3. How to build an Arduino Project 73