Lesson 6: The Serial Monitor
Trang này cần trình duyệt gần đây (hỗ trợ SharedArrayBuffer). Vui lòng cập nhật Chrome, Edge, Firefox hoặc Safari lên phiên bản mới nhất.
English
The board can talk
Serial.begin(9600);opens the cable to the computer at 9600 bits per second.Serial.println("Hi");sends a line. You see it under the board, in the Serial Monitor.Serial.printdoes the same without a new line.
int count = 0;
void setup() {
Serial.begin(9600);
Serial.println("Hello!");
}
void loop() {
count = count + 1;
Serial.print("Count: ");
Serial.println(count);
delay(1000);
}
- This is how Arduino programmers find bugs: print the numbers and look at them.
English
In the exam
"Serial" in Serial.begin means serial data transmission: the bits go one after the other down one wire. At 9600 bits per second, one letter (8 bits plus 2 control bits) takes about 1 ms.
- 0478/12/M/J/23 Q4(a): (i) Describe serial data transmission: data is sent one bit at a time, down a single wire. (ii) Two benefits: the bits cannot get out of order (no skew), and there is less chance of interference and errors. (iii) A benefit of parallel transmission instead: it can be faster, because several bits go at the same time on several wires.
Độ khó 1/5 · 100 xu + phần thưởng nhỏ khi hoàn thành lần đầu tiên hôm nay
Print Hello, Arduino! once, when the board starts.
Nhấn Chạy để xem kết quả ở đây.
Độ khó 2/5 · 140 xu + phần thưởng nhỏ khi hoàn thành lần đầu tiên hôm nay
Count down: print 5, 4, 3, 2, 1 (one number on each line), then Go!. Use a for loop in setup().
Nhấn Chạy để xem kết quả ở đây.