SunFounder 3in1 Kit
(continued from previous page)
void loop() {
// put your main code here, to run repeatedly:
digitalWrite(13,HIGH);
delay(500);
digitalWrite(13,LOW);
delay(500);
}
Next, let’s take a look at the following two sketches and guess if they can be correctly recognized by Arduino before
running them.
Sketch A:
void setup() {
// put your setup code here, to run once:
pinMode(13,OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
digitalWrite(13,HIGH)
delay(500)
digitalWrite(13,LOW)
delay(500)
}
Sketch B:
void setup() {
// put your setup code here, to run once:
pinMode(13,OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
digitalWrite(13,
HIGH); delay
(500
);
digitalWrite(13,
LOW);
delay(500)
;
}
The result is that Sketch A reports an error and Sketch B runs.
• The errors in Sketch A are missing ; and although it looks normal, the Arduino can’t read it.
• Sketch B, looks anti-human, but in fact, indentation, line breaks and spaces in statements are things that do not
exist in Arduino programs, so to the Arduino compiler, it looks the same as in the example.
However, please don’t write your code as Sketch B, because it is usually natural people who write and view the code,
70 Chapter 2. Get Started with Arduino