The Arduino writes to you: Serial
Section 9: From blocks to C++ codeLesson 9.3 · ⏱ 6 min
Serial.println makes the Arduino write a line in the Serial Monitor under the code. Engineers use it to know what is happening inside the program.
void setup() {
Serial.begin(9600);
Serial.println("Youssef");
}
void loop() {
}
🖥️ The Serial in Robo Maker:
Youssef

📌 Another example: two lines
The Arduino writes two lines: the greeting, then the question.
void setup() {
Serial.begin(9600);
Serial.println("Hello!");
Serial.println("How are you?");
}
void loop() {
}
Hello!
How are you?
✍️ Practise
Write your name in English.
✍️ Practise here in the lesson✖ Close the labor open the lab in a new page ↗
🎯 Challenge yourself
Easy
Write your name and your city on two lines.
👀 Show the solution🙈 Hide the solution
void setup() {
Serial.begin(9600);
Serial.println("Mona");
Serial.println("Cairo");
}
void loop() {
}
Mona
Cairo
Result: two lines: the name and the city.
Medium
print without ln: write “Robo” and “Egypt” on the same line.
👀 Show the solution🙈 Hide the solution
void setup() {
Serial.begin(9600);
Serial.print("Robo ");
Serial.println("Egypt");
}
void loop() {
}
Robo Egypt
Result: Robo Egypt on one line.
Hard
Write “Hi” every second, inside loop.
👀 Show the solution🙈 Hide the solution
void setup() {
Serial.begin(9600);
}
void loop() {
Serial.println("Hi");
delay(1000);
}
Hi
Hi
Hi
Hi
Result: it repeats every second.

