Chapterبەش 4 · Lectureوانە 4.2

Lab: Talking to the Board with the Serial Monitorتاقیگە: قسەکردن لەگەڵ بۆرد بە Serial Monitor

Make the board talk: Serial.begin() and the baud rate, print() and println(), and reading commands with Serial.available() and Serial.read(). See what the Serial Monitor's line-ending menu really sends (R, then \n), then run the session's labs — R/Y/G/O commands, small letters, LED patterns with for loops, toggles with switch and !, and a serial password check — with their real mistakes found and fixed. Learn why delay() makes the board deaf, how millis() keeps it listening, and why a password must never live in the code.

بۆردەکە بخەرە قسە: ⁦Serial.begin()⁩ و ، ⁦print()⁩ و ⁦println()⁩ و خوێندنەوەی فەرمان بە ⁦Serial.available()⁩ و ⁦Serial.read()⁩. ببینە کۆتایی دێڕی بەڕاستی چی دەنێرێت (R، پاشان \n)، پاشان تاقیگەکانی دانیشتنەکە جێبەجێ بکە — فەرمانەکانی ⁦R/Y/G/O⁩، پیتی بچووک، شێوەی بە ، گۆڕین بە switch و ! و پشکنینی بە Serial — لەگەڵ دۆزینەوە و چاککردنی هەڵە ڕاستەقینەکانیان. فێر ببە بۆچی ⁦delay()⁩ بۆردەکە کەڕ دەکات، ⁦millis()⁩ چۆن بە گوێگرتوویی دەیهێڵێتەوە و بۆچی هەرگیز نابێت لە ناو کۆددا بێت.

27 min read27 خولەک خوێندنەوە · 23 stepsهەنگاو

What you will learnچی فێر دەبیت

  • Open serial communication with Serial.begin(), choose a matching baud rate and explain what a baud rate means.
  • Send text with print() and println(), and read commands with Serial.available(), Serial.read() and readStringUntil().
  • Explain the line-ending menu and handle the '\n' and '\r' that arrive with each command.
  • Control LEDs with if/else, ||, switch, ! and for loops, and find and fix the labs' mistakes.
  • Explain why delay() blocks, use millis() to keep listening, and say why passwords must not be written in code.
  • بە ⁦Serial.begin()⁩ بکەرەوە، گونجاو هەڵبژێرە و ڕوون بکەرەوە واتە چی.
  • بە ⁦print()⁩ و ⁦println()⁩ دەق بنێرە و بە ⁦Serial.available()⁩، ⁦Serial.read()⁩ و ⁦readStringUntil()⁩ فەرمان بخوێنەرەوە.
  • کۆتایی دێڕ ڕوون بکەرەوە و ئەو '\n' و '\r'ـانە چارەسەر بکە کە لەگەڵ هەر فەرمانێک دەگەن.
  • بە ⁦if/else⁩، ⁦||⁩، switch، ! و کۆنترۆڵ بکە و هەڵەکانی تاقیگەکان بدۆزەرەوە و چاکیان بکەرەوە.
  • ڕوون بکەرەوە بۆچی ⁦delay()⁩ ڕێگرە، ⁦millis()⁩ بۆ بەردەوامبوون لە گوێگرتن بەکار بهێنە و بڵێ بۆچی نابێت لە ناو کۆددا بنووسرێت.

A conversation over USBگفتوگۆیەک بە USB

A board has no screen and no keyboard, so how does it tell you what it is doing, or take an order from you? Through the USB cable that brought its sketch. The Serial Monitor of the Arduino IDE shows the text the board sends and sends the text you type. This serial communication moves one bit after another along the line, like spelling a word letter by letter; on the board the (or the USB part of the chip) sends and receives the bits.

بۆرد شاشە و نییە، کەواتە چۆن پێت دەڵێت چی دەکات، یان فەرمانێکت لێ وەردەگرێت؟ بە هەمان کێبڵی کە هێنا. ـی Arduino IDE ئەو دەقە پیشان دەدات کە بۆردەکە دەینێرێت و ئەو دەقە دەنێرێت کە تۆ دەینووسیت. ئەم ـە یەک لە دوای یەک بە هێڵەکەدا دەگوازێتەوە، وەک ئەوەی وشەیەک پیت بە پیت بڵێیت؛ لەسەر بۆردەکە (یان بەشی ) دەنێرێت و وەردەگرێت.

A laptop showing the Serial Monitor at 9600 baud, with R typed in the message box and three lines Hello, Aram! below, is joined by a USB cable to an Arduino UNO whose TX and RX lights are on. An arrow from the board to the laptop says board → computer: text; an arrow from the laptop to the board says computer → board: commands. Under the cable eight boxes show the bits 0 1 0 0 1 0 0 0: one character is bits in a row, H = 01001000.لاپتۆپێک کە Serial Monitor بە 9600 baud پیشان دەدات، R لە خانەی پەیامدا نووسراوە و سێ دێڕی Hello, Aram! لە خوارەوەیە، بە کێبڵێکی USB بە Arduino UNOـێکەوە بەستراوە کە گڵۆپەکانی TX و RXـی داگیرساون. تیرێک لە بۆردەکەوە بۆ لاپتۆپەکە دەڵێت بۆرد ← کۆمپیوتەر: دەق؛ تیرێک لە لاپتۆپەکەوە بۆ بۆردەکە دەڵێت کۆمپیوتەر ← بۆرد: فەرمان. لە ژێر کێبڵەکەدا هەشت خانە بیتەکان 0 1 0 0 1 0 0 0 پیشان دەدەن: یەک نووسە واتە بیتەکان لە ڕیزێکدا، H = 01001000.
Text goes both ways over the same USB cable, one bit after another.دەق بە هەمان کێبڵی بە هەردوو ئاراستە دەڕوات، لە دوای .CêIT

Serial.begin(9600): open the line at the right speed⁦Serial.begin(9600)⁩: هێڵەکە بە خێراییەکی دروست بکەرەوە

Serial is a built-in object for sending and receiving data, and Serial.begin(9600) starts it — begin means start — usually in setup(). The number is the baud rate, the speed: 9600 bits per second, a common choice for simple projects. Other usual speeds are 4800, 19200 and 115200. The sketch and the Serial Monitor's baud menu must use the same speed, or the text turns into strange symbols (a later lab shows this mistake at 115200 baud: the Serial Monitor at the wrong speed).

Serial ئۆبجێکتێکی ئامادەیە بۆ ناردن و وەرگرتنی و Serial.begin(9600) دەستی پێ دەکات — begin واتە دەستپێکردن — زۆرجار لە setup()ـدا. ژمارەکە ـە، واتە خێرایی: ⁦9600⁩ لە چرکەیەکدا، هەڵبژاردنێکی باو بۆ پڕۆژەی سادە. خێرایییە باوەکانی تر ⁦4800⁩، ⁦19200⁩ و ⁦115200⁩ـن. و baudـی دەبێت هەمان خێرایی بەکار بهێنن، ئەگینا دەقەکە دەبێتە هێمای سەیر (تاقیگەیەکی دواتر ئەم هەڵەیە بە ⁦115200 baud⁩ پیشان دەدات: Serial Monitor بە خێرایی هەڵە).

By default each character travels as 10 bits: a start bit, 8 data bits (lowest bit first) and a stop bit. So 9600 baud carries about 960 characters a second. Boards with native USB, such as the UNO R4 Minima and the MKR family, ignore the number on their USB port, but it matters on the real serial pins 0 and 1 and on an UNO R3, so set both sides alike.

بە شێوەی بنەڕەتی هەر وەک ⁦10⁩ دەڕوات: دەستپێک، 8 (بچووکترین یەکەم) و کۆتایی. بۆیە ⁦9600 baud⁩ نزیکەی ⁦960⁩ لە چرکەیەکدا دەگوازێتەوە. ئەو بۆردانەی ڕاستەوخۆیان هەیە، وەک ⁦UNO R4 Minima⁩ و خێزانی MKR، لەسەر ژمارەکە پشتگوێ دەخەن، بەڵام لەسەر پینە زنجیرەییە ڕاستەقینەکانی 0 و 1 و لە ⁦UNO R3⁩ـدا گرنگە، بۆیە هەردوو لا وەک یەک دابنێ.

A timing diagram of one character, H, on the serial line. The line rests HIGH (idle), drops LOW for the start bit, then carries the eight data bits b0 to b7 lowest bit first, 0 0 0 1 0 0 1 0, then goes HIGH for the stop bit and rests again. A bracket under the data bits says H = 72 = 0b01001000, sent lowest bit first. A box below: 1 bit = 1 ÷ 9600 s ≈ 104 µs, 10 bits per character; 9600 ÷ 10 ≈ 960 characters per second.هێڵکاریی کاتبەندییەکی یەک نووسە، H، لەسەر هێڵی زنجیرەیی. هێڵەکە لەسەر HIGH پشوو دەدات (بێکار)، بۆ بیتی دەستپێک دادەبەزێتە LOW، پاشان هەشت بیتی دراوە b0 تا b7 دەگوازێتەوە، بچووکترین بیت یەکەم، 0 0 0 1 0 0 1 0، پاشان بۆ بیتی کۆتایی دەبێتە HIGH و دووپاتە پشوو دەدات. کەوانەیەک لە ژێر بیتەکانی دراوە دەڵێت H = 72 = 0b01001000، بچووکترین بیت یەکەم دەنێردرێت. خانەیەک لە خوارەوە: 1 بیت = 1 ÷ 9600 s ≈ 104 µs، 10 بیت بۆ هەر نووسەیەک؛ 9600 ÷ 10 ≈ 960 نووسە لە چرکەیەکدا.
One character on the wire: start bit, 8 data bits, stop bit (8-N-1).یەک لەسەر وایەرەکە: دەستپێک، 8 ، کۆتایی ⁦(8-N-1)⁩.CêIT

Hello from the boardسڵاو لە بۆردەکەوە

The smallest Serial sketch sends one line every second. The text between the double quotes is a string; put your own name in it.

بچووکترین Serial هەر چرکەیەک دێڕێک دەنێرێت. ئەو دەقەی لە نێوان ـە؛ ناوی خۆتی تێدا بنووسە.

Hello once a secondسڵاو هەر چرکەیەکhello.inoARDUINORuns on a phone (or an emulator)لەسەر مۆبایل کار دەکات
void setup() {
  Serial.begin(9600);              // open the serial line at 9600 baud
}

void loop() {
  Serial.println("Hello, Aram!");  // send one line to the computer
  delay(1000);                     // wait 1 second
}
Explain the codeڕوونکردنەوەی کۆدەکە
Lineدێڕی 2

Open the serial line at 9600 baud, once.

هێڵی زنجیرەیی بە ⁦9600 baud⁩ دەکاتەوە، یەک جار.

Lineدێڕی 6-7

Send a line, wait a second, and again.

دێڕێک دەنێرێت، چرکەیەک چاوەڕێ دەکات و دووپاتە.

Listening: Serial.available() and Serial.read()گوێگرتن: ⁦Serial.available()⁩ و ⁦Serial.read()⁩

Bytes that arrive from the computer wait in a small receive buffer (64 bytes). Serial.available() says how many are waiting; Serial.read() takes the oldest one, or returns −1 if none is there. So a listening sketch always asks first: if (Serial.available() > 0) { char command = Serial.read(); … }. A char holds one character and is written in single quotes, 'R'; a string uses double quotes, "R" (char: one character).

ئەو لە دێن لە وەرگرتنی بچووکدا (⁦64⁩ ) چاوەڕێ دەکەن. Serial.available() دەڵێت چەندیان چاوەڕێن؛ Serial.read() کۆنترینیان وەردەگرێت، یان ئەگەر هیچ نەبێت ⁦−1⁩ دەگەڕێنێتەوە. بۆیە کە گوێ دەگرێت هەمیشە سەرەتا دەپرسێت: if (Serial.available() > 0) { char command = Serial.read(); … }. char یەک هەڵدەگرێت و لە نێوان دەنووسرێت، 'R'؛ بەکار دەهێنێت، "R" (char: یەک نووسە).

Three steps of the receive buffer, a row of slots. Step 1: R and \n wait in the first two slots; available() → 2, two bytes are waiting. Step 2: read() → 82, R has left and only \n waits; available() → 1; the byte R is 82 in ASCII. Step 3: read() → 10, \n has left and the buffer is empty; available() → 0; the byte \n is 10 in ASCII. Note: read() takes the oldest byte; with nothing waiting it returns −1.سێ هەنگاوی بافەری وەرگرتن، ڕیزێک خانە. هەنگاوی 1: R و \n لە دوو خانەی یەکەمدا چاوەڕێن؛ available() → 2، دوو بایت چاوەڕێن. هەنگاوی 2: read() → 82، R دەرچوو و تەنیا \n چاوەڕێیە؛ available() → 1؛ بایتی R بە ASCII 82ـە. هەنگاوی 3: read() → 10، \n دەرچوو و بافەرەکە بەتاڵە؛ available() → 0؛ بایتی \n بە ASCII 10ـە. تێبینی: read() کۆنترین بایت وەردەگرێت؛ کاتێک هیچ چاوەڕێ ناکات −1 دەگەڕێنێتەوە.
available() counts the waiting bytes; read() takes the oldest.⁦available()⁩ چاوەڕێکان دەژمێرێت؛ ⁦read()⁩ کۆنترینیان وەردەگرێت.CêIT

The line-ending menuمێنیوی کۆتایی دێڕ

Beside the baud menu, the Serial Monitor has a line-ending menu. When you press Enter, the IDE sends your text and then adds the chosen ending: No Line Ending adds nothing; New Line adds \n and is the default of the IDE 2; Carriage Return adds \r; Both NL & CR adds \r\n. The names come from typewriters and teleprinters: the carriage went back to the start of the line, and the paper moved up one line.

لە تەنیشت baud، کۆتایی دێڕـی هەیە. کاتێک Enter دادەگریت، IDEـەکە دەقەکەت دەنێرێت و پاشان کۆتاییە هەڵبژێردراوەکە زیاد دەکات: No Line Ending هیچ زیاد ناکات؛ New Line \n زیاد دەکات و لە ⁦IDE 2⁩ـدا بنەڕەتە؛ Carriage Return \r زیاد دەکات؛ ⁦Both NL & CR⁩ هەردووکیان زیاد دەکات، \r\n. ناوەکان لە ئامێری تایپ و تێلێپرینتەرەوە هاتوون: گالیسکەکە دەگەڕایەوە بۆ سەرەتای دێڕ و کاغەزەکە یەک دێڕ دەچووە سەرەوە.

The Serial Monitor tab of the IDE. The message box contains R with the cursor after it, labelled type, then press Enter. Beside it the line-ending menu is open with four choices, No Line Ending, New Line (ticked), Carriage Return and Both NL & CR, labelled added after your text (default: New Line). Next to it the baud menu shows 9600 baud, labelled must match Serial.begin(). Below, the output shows Send R, Y, G or O (all off). and Unknown command: X.بەشی Serial Monitorـی IDE. خانەی پەیام R و نیشاندەرێکی دوای تێدایە، بە ناوی بنووسە، پاشان Enter دابگرە. لە تەنیشتییەوە مێنیوی کۆتایی دێڕ کراوەتەوە بە چوار هەڵبژاردەوە، No Line Ending، New Line (هەڵبژێردراو)، Carriage Return و Both NL & CR، بە ناوی دوای دەقەکەت زیاد دەکرێت (بنەڕەت: New Line). لە تەنیشتییەوە مێنیوی baud نووسینی 9600 baud پیشان دەدات، بە ناوی دەبێت لەگەڵ Serial.begin() یەک بگرێتەوە. لە خوارەوە دەرخستەکە Send R, Y, G or O (all off). و Unknown command: X پیشان دەدات.
Three controls of the Serial Monitor: message box, line-ending menu and baud menu.سێ کۆنترۆڵی : خانەی پەیام، کۆتایی دێڕ و baud.CêIT

The line-ending menuمێنیوی کۆتایی دێڕ

What the board really receives: R, then \nبۆردەکە بەڕاستی چی وەردەگرێت: R، پاشان \n

This sketch prints the number of every byte it receives. Type R with New Line, then Y with Both NL & CR, then G with No Line Ending:

ئەم ژمارەی هەر کە وەری دەگرێت چاپ دەکات. R بە New Line بنووسە، پاشان Y بە ⁦Both NL & CR⁩، پاشان G بە No Line Ending:

Show every byte that arrivesهەر بایتێک کە دەگات پیشان بدەwhat_arrives.inoARDUINORuns on a phone (or an emulator)لەسەر مۆبایل کار دەکات
// What does the board really receive? Print each byte's number.
void setup() {
  Serial.begin(9600);
  Serial.println("Type a letter and press Enter.");
}

void loop() {
  if (Serial.available() > 0) {     // is at least one byte waiting?
    int b = Serial.read();          // take the first byte
    Serial.print("byte ");
    Serial.print(b);                // its number (ASCII code)
    if (b == '\n') {
      Serial.println(" = \\n (new line)");
    } else if (b == '\r') {
      Serial.println(" = \\r (carriage return)");
    } else {
      Serial.print(" = '");
      Serial.print((char)b);
      Serial.println("'");
    }
  }
}
Explain the codeڕوونکردنەوەی کۆدەکە
Lineدێڕی 9-11

Read one byte and print its number (its ASCII code).

یەک دەخوێنێتەوە و ژمارەکەی (کۆدی ) چاپ دەکات.

Lineدێڕی 12-15

Name the two invisible ones: \n and \r.

دوو نادیارەکە ناو دەبات: \n و \r.

The numbers are ASCII codes (Control characters): R is 82, the newline \n is 10 and the carriage return \r is 13. A sketch that reads one character at a time therefore receives the line ending as a character too — the cause of the next two mistakes.

ژمارەکان کۆدی (نووسەکانی کۆنترۆڵ): کۆدی ⁦R 82⁩ـە، کۆدی (\n) ⁦10⁩ـە و کۆدی (\r) ⁦13⁩ـە. کەواتە کە هەر جارە یەک دەخوێنێتەوە کۆتایی دێڕەکەش وەک وەردەگرێت — هۆی دوو هەڵەکەی داهاتوو.

You type R and press Enter. Four rows show what the board receives for each line ending, with ASCII codes. No Line Ending: R (82), 1 byte. New Line, the default: R (82) and \n (10), 2 bytes. Carriage Return: R (82) and \r (13), 2 bytes. Both NL & CR: R (82), \r (13) and \n (10), 3 bytes.R دەنووسیت و Enter دادەگریت. چوار ڕیز پیشان دەدەن بۆردەکە بۆ هەر کۆتاییەکی دێڕ چی وەردەگرێت، لەگەڵ کۆدی ASCII. No Line Ending: R (82)، 1 بایت. New Line، بنەڕەت: R (82) و \n (10)، 2 بایت. Carriage Return: R (82) و \r (13)، 2 بایت. Both NL & CR: R (82)، \r (13) و \n (10)، 3 بایت.
Enter is not nothing: it sends one or two extra bytes.Enter بەتاڵ نییە: یەک یان دوو زیادە دەنێرێت.CêIT

Lab 3: commands R, Y, G and Oتاقیگەی 3: فەرمانەکانی R، Y، G و O

Lab 3 turns the Serial Monitor into a remote control for the three LEDs of Lab 2 (UNO, pins 2, 3 and 4): R lights red, Y yellow, G green, and O switches all of them off. This is the corrected version:

تاقیگەی 3 دەکات بە ڕیمۆتێک بۆ سێ تاقیگەی 2 (UNO، پینەکانی 2، 3 و ⁦4): R⁩ سوور هەڵدەکات، Y زەرد، G سەوز و O هەموویان دەکوژێنێتەوە. ئەمە وەشانە چاککراوەکەیە:

Lab 3, correctedتاقیگەی 3، چاککراوrygo_fixed.inoARDUINORuns on a phone (or an emulator)لەسەر مۆبایل کار دەکات
// Lab 3: control three LEDs from the Serial Monitor (Arduino UNO)
const int redPin = 2;
const int yellowPin = 3;
const int greenPin = 4;

void setup() {
  Serial.begin(9600);
  pinMode(redPin, OUTPUT);
  pinMode(yellowPin, OUTPUT);
  pinMode(greenPin, OUTPUT);
  Serial.println("Send R, Y, G or O (all off).");
}

void loop() {
  if (Serial.available() > 0) {
    char command = Serial.read();

    if (command == '\n' || command == '\r') {
      return;                        // the Enter key is not a command
    }

    if (command == 'R') {
      digitalWrite(redPin, HIGH);
      digitalWrite(yellowPin, LOW);
      digitalWrite(greenPin, LOW);
    } else if (command == 'Y') {
      digitalWrite(redPin, LOW);
      digitalWrite(yellowPin, HIGH);
      digitalWrite(greenPin, LOW);
    } else if (command == 'G') {
      digitalWrite(redPin, LOW);
      digitalWrite(yellowPin, LOW);
      digitalWrite(greenPin, HIGH);
    } else if (command == 'O') {
      digitalWrite(redPin, LOW);
      digitalWrite(yellowPin, LOW);
      digitalWrite(greenPin, LOW);
    } else {
      Serial.print("Unknown command: ");
      Serial.println(command);
    }
  }
}
Explain the codeڕوونکردنەوەی کۆدەکە
Lineدێڕی 18-20

The Enter key's \n (and \r) is not a command: || means or, and return leaves loop() early; loop() is called again at once.

\n (و \r)ـی Enter فەرمان نییە: || واتە یان و return بە زوویی لە ⁦loop()⁩ دەردەچێت؛ ⁦loop()⁩ یەکسەر دووپاتە بانگ دەکرێتەوە.

Lineدێڕی 22-37

Each branch writes all three pins, always in the same order: red, yellow, green.

هەر بەشێک هەر سێ پینەکە دەنووسێت، هەمیشە بە هەمان ڕیز: سوور، زەرد، سەوز.

Lineدێڕی 38-41

An unknown character is named, so the user knows what went wrong.

نەناسراو ناو دەبرێت، بۆ ئەوەی بزانێت چی هەڵە بوو.

An animation in five steps with a Serial Monitor on the left and three LEDs, on pins 2, 3 and 4, on the right; each step shows the letter typed and the two bytes sent, the letter and \n. 1: R, red on, the others off. 2: Y, yellow on. 3: G, green on, and yellow really goes off. 4: O, all off. 5: X, not a command, so the monitor shows Unknown command: X; the \n sent by Enter is ignored.
An animation in five steps with a Serial Monitor on the left and three LEDs, on pins 2, 3 and 4, on the right; each step shows the letter typed and the two bytes sent, the letter and \n. 1: R, red on, the others off. 2: Y, yellow on. 3: G, green on, and yellow really goes off. 4: O, all off. 5: X, not a command, so the monitor shows Unknown command: X; the \n sent by Enter is ignored.
The corrected Lab 3 answering five commands.تاقیگەی 3ـی چاککراو وەڵامی پێنج فەرمان دەداتەوە.CêIT

Lab 3: commands R, Y, G and Oتاقیگەی 3: فەرمانەکانی R، Y، G و O

Common mistake: the yellow LED that stays onهەڵەی باو: LEDـە زەردەکە کە هەڵکراو دەمێنێتەوە

Two panels after the commands Y and then G. Left, the first version's G branch: yellow and green are both lit; the code lines digitalWrite(greenPin, HIGH); digitalWrite(redPin, LOW); digitalWrite(redPin, LOW); with the last line highlighted; note: red is switched off twice; yellow never. Right, fixed: only green is lit; the lines digitalWrite(redPin, LOW); digitalWrite(yellowPin, LOW); digitalWrite(greenPin, HIGH); with the yellow line highlighted; note: each branch writes all three pins.دوو بەش دوای فەرمانەکانی Y و پاشان G. چەپ، بەشی Gـی یەکەم وەشان: زەرد و سەوز هەردووکیان داگیرساون؛ دێڕەکانی کۆد digitalWrite(greenPin, HIGH); digitalWrite(redPin, LOW); digitalWrite(redPin, LOW); و دوایین دێڕ دیاری کراوە؛ تێبینی: سوور دوو جار دەکوژێنرێتەوە؛ زەرد هەرگیز. ڕاست، چاککراو: تەنیا سەوز داگیرساوە؛ دێڕەکانی digitalWrite(redPin, LOW); digitalWrite(yellowPin, LOW); digitalWrite(greenPin, HIGH); و دێڕی زەرد دیاری کراوە؛ تێبینی: هەر بەشێک هەر سێ پینەکە دەنووسێت.
One copied line left the yellow LED on.یەک دێڕی کۆپیکراو زەردەکەی بە هەڵکراوی هێشتەوە.CêIT

Lab 3: commands R, Y, G and Oتاقیگەی 3: فەرمانەکانی R، Y، G و O

Common mistake: the Enter key becomes a commandهەڵەی باو: دوگمەی Enter دەبێتە فەرمان

Two bytes arrive one after the other. The first, R, goes to a test box R? Y? G? O?: yes, red on, and the red LED lights. The second, \n, goes to the same test: no, the else branch, and the Serial Monitor shows Not working With Characters. Below: fix 1, ignore the newline and the carriage return in the sketch; fix 2, choose No Line Ending. Fix 1 is better: it works with every line-ending setting.دوو بایت یەک لە دوای یەک دەگەن. یەکەمیان، R، دەچێتە خانەی تاقیکردنەوەی R? Y? G? O?: بەڵێ، سوور هەڵدەبێت و LEDـە سوورەکە دادەگیرسێت. دووەمیان، \n، دەچێتە هەمان تاقیکردنەوە: نەخێر، بەشی else و Serial Monitor دەقی Not working With Characters پیشان دەدات. لە خوارەوە: چارەسەری 1، لە سکێچەکەدا دێڕی نوێ و گەڕانەوەی سەری دێڕ پشتگوێ بخە؛ چارەسەری 2، No Line Ending هەڵبژێرە. چارەسەری 1 باشترە: لەگەڵ هەموو ڕێکخستنێکی کۆتایی دێڕ کار دەکات.
The second byte of every command is the Enter key. دووەمی هەموو فەرمانێک Enterـە.CêIT

Task 3: small letters too, and a confirmationئەرکی 3: پیتی بچووکیش و پشتڕاستکردنەوە

Task 3 asks for two changes: accept r, y, g and o as well, and confirm each command. || means or: command == 'R' || command == 'r' is true for either letter (another way is toupper(command) == 'R', which first turns a small letter into a capital). The confirmation now depends on known, a boolean variable that remembers whether the command was valid:

ئەرکی 3 داوای دوو گۆڕانکاری دەکات: r، y، g و oـیش وەربگرە و هەر فەرمانێک پشتڕاست بکەرەوە. || واتە یان: command == 'R' || command == 'r' بۆ هەر یەک لە دوو پیتەکە ڕاستە (ڕێگایەکی تر toupper(command) == 'R'ـە کە سەرەتا پیتی بچووک دەکاتە گەورە). پشتڕاستکردنەوەکە ئێستا بەستراوە بە known، کە لەبیری دەمێنێت ئایا فەرمانەکە دروست بوو:

Task 3, correctedئەرکی 3، چاککراوtask3_fixed.inoARDUINORuns on a phone (or an emulator)لەسەر مۆبایل کار دەکات
// Task 3: capital or small letters, and a confirmation
const int redPin = 2;
const int yellowPin = 3;
const int greenPin = 4;

void setup() {
  Serial.begin(9600);
  pinMode(redPin, OUTPUT);
  pinMode(yellowPin, OUTPUT);
  pinMode(greenPin, OUTPUT);
  Serial.println("Send R, Y, G or O (small letters work too).");
}

void loop() {
  if (Serial.available() > 0) {
    char command = Serial.read();
    if (command == '\n' || command == '\r') {
      return;                               // ignore the Enter key
    }

    bool known = true;                      // is it one of our commands?
    if (command == 'R' || command == 'r') {
      digitalWrite(redPin, HIGH);
      digitalWrite(yellowPin, LOW);
      digitalWrite(greenPin, LOW);
    } else if (command == 'Y' || command == 'y') {
      digitalWrite(redPin, LOW);
      digitalWrite(yellowPin, HIGH);
      digitalWrite(greenPin, LOW);
    } else if (command == 'G' || command == 'g') {
      digitalWrite(redPin, LOW);
      digitalWrite(yellowPin, LOW);
      digitalWrite(greenPin, HIGH);
    } else if (command == 'O' || command == 'o') {
      digitalWrite(redPin, LOW);
      digitalWrite(yellowPin, LOW);
      digitalWrite(greenPin, LOW);
    } else {
      known = false;
    }

    if (known) {
      Serial.print("Done: ");               // confirm only real commands
    } else {
      Serial.print("Unknown command: ");
    }
    Serial.println(command);
  }
}
Explain the codeڕوونکردنەوەی کۆدەکە
Lineدێڕی 21

known starts true; the else branch sets it to false.

known بە true دەست پێ دەکات؛ دەیکاتە false.

Lineدێڕی 42-47

Confirm only real commands; name unknown ones.

تەنیا فەرمانی ڕاستەقینە پشتڕاست بکەرەوە؛ نەناسراوەکان ناو ببە.

A flow chart. command = Serial.read(). Is it the newline or the carriage return? Yes: ignore it (return). No: is it R or r, Y or y, G or g, O or o? Yes: set the LEDs and print Done: r. No: print Unknown command: x. A side box shows two ways to accept r and R: c == 'R' || c == 'r', and toupper(c) == 'R'.هێڵکارییەکی ڕەوت. command = Serial.read(). ئایا نووسەی دێڕی نوێ یان گەڕانەوەی سەری دێڕە؟ بەڵێ: پشتگوێی بخە (return). نەخێر: ئایا R یان r، Y یان y، G یان g، O یان oـیە؟ بەڵێ: LEDـەکان ڕێک بخە و Done: r چاپ بکە. نەخێر: Unknown command: x چاپ بکە. خانەیەکی لاتەنیشت دوو ڕێگا بۆ وەرگرتنی r و R پیشان دەدات: c == 'R' || c == 'r' و toupper(c) == 'R'.
Task 3's decisions, in order.بڕیارەکانی ئەرکی 3، بە ڕیز.CêIT

Lab 4: LED patterns with for loopsتاقیگەی 4: شێوەی LED بە خولی for

Lab 4 runs a pattern for each number: 1 blinks red ten times, 2 blinks yellow five times and 3 flashes green once. A for loop repeats a block a counted number of times (The three parts of a for header); here i counts 0, 1, …, 9. Nothing happens for 4 or 9: no branch matches and there is no else, so the Enter key's '\n' is quietly ignored too.

تاقیگەی 4 بۆ هەر ژمارەیەک شێوەیەک جێبەجێ دەکات: 1 سوور دە جار دەترووکێنێت، 2 زەرد پێنج جار و 3 سەوز یەک جار. بلۆکێک بە ژمارەیەکی دیاریکراو دووپاتە دەکاتەوە (سێ بەشی سەری for)؛ لێرەدا i دەژمێرێت 0، 1، …، 9. بۆ 4 یان 9 هیچ ڕوو نادات: هیچ بەشێک یەک ناگرێتەوە و else نییە، بۆیە '\n'ـی Enterـیش بە بێدەنگی پشتگوێ دەخرێت.

Lab 4: three patternsتاقیگەی 4: سێ شێوەpatterns.inoARDUINORuns on a phone (or an emulator)لەسەر مۆبایل کار دەکات
// Lab 4: LED patterns chosen by a number
const int redPin = 2;
const int yellowPin = 3;
const int greenPin = 4;

void setup() {
  Serial.begin(9600);
  pinMode(redPin, OUTPUT);
  pinMode(yellowPin, OUTPUT);
  pinMode(greenPin, OUTPUT);
  Serial.println("Send 1, 2 or 3 to run an LED pattern.");
}

void loop() {
  if (Serial.available() > 0) {
    char input = Serial.read();

    if (input == '1') {                  // red blinks 10 times
      for (int i = 0; i < 10; i++) {
        digitalWrite(redPin, HIGH);
        delay(200);
        digitalWrite(redPin, LOW);
        delay(200);
      }
    } else if (input == '2') {           // yellow blinks 5 times
      for (int i = 0; i < 5; i++) {
        digitalWrite(yellowPin, HIGH);
        delay(200);
        digitalWrite(yellowPin, LOW);
        delay(200);
      }
    } else if (input == '3') {           // green blinks once
      digitalWrite(greenPin, HIGH);
      delay(200);
      digitalWrite(greenPin, LOW);
      delay(200);
    }
  }
}
Explain the codeڕوونکردنەوەی کۆدەکە
Lineدێڕی 19-24

Ten times: on 200 ms, off 200 ms.

دە جار: ⁦200 ms⁩ هەڵکراو، ⁦200 ms⁩ کوژاو.

Three timing rows from 0 to 8 seconds, red on pin 2, yellow on pin 3 and green on pin 4, with the typed commands 1 at 0.3 s, 2 at 4.6 s and 3 at 7.0 s marked above. Red pulses ten times between 0.3 and 4.3 s; yellow pulses five times between 4.6 and 6.6 s; green pulses once at 7.0 s.سێ ڕیزی کات لە 0 تا 8 چرکە، سوور لەسەر پینی 2، زەرد لەسەر پینی 3 و سەوز لەسەر پینی 4، لەگەڵ فەرمانە نووسراوەکانی 1 لە 0.3 چرکە، 2 لە 4.6 چرکە و 3 لە 7.0 چرکە لە سەرەوە. سوور لە نێوان 0.3 و 4.3 چرکەدا دە تڕپە دەدات؛ زەرد لە نێوان 4.6 و 6.6 چرکەدا پێنج تڕپە؛ سەوز یەک تڕپە لە 7.0 چرکەدا.
Lab 4's three patterns, as the checker logged them.سێ شێوەکەی تاقیگەی 4، وەک پشکنەرەکە تۆماری کردن.CêIT

Lab 4: LED patterns with for loopsتاقیگەی 4: شێوەی LED بە خولی for

Task 4: a chaseئەرکی 4: ڕاکردنی ڕووناکی

ExerciseڕاهێنانTask 4ئەرکی 4

Add pattern 4: red, yellow and green each flash once for 200 ms, one after another, like a light running along. Update the start message too.

شێوەی 4 زیاد بکە: سوور، زەرد و سەوز هەریەکە یەک جار بۆ ⁦200 ms⁩ دەترووکێن، یەک لە دوای یەک، وەک ڕووناکییەک کە ڕادەکات. پەیامی سەرەتاش نوێ بکەرەوە.

Hintئاماژە

Copy one blink block three times, or put the pins in an array.

یەک بلۆکی ترووسکاندن سێ جار کۆپی بکە، یان پینەکان بخەرە ناو .

Show answerوەڵامەکە پیشان بدە
Task 4: the new branchئەرکی 4: بەشە نوێیەکەtask4.inoARDUINORuns on a phone (or an emulator)لەسەر مۆبایل کار دەکات
} else if (input == '4') {           // chase: red, yellow, green
  int pins[] = {redPin, yellowPin, greenPin};
  for (int i = 0; i < 3; i++) {
    digitalWrite(pins[i], HIGH);
    delay(200);
    digitalWrite(pins[i], LOW);
    delay(200);
  }
}

An array pins[] holds the three pin numbers, so one for loop visits them in turn (Arrays). Writing the three blocks out one after another also works. The start message becomes Send 1, 2, 3 or 4 to run an LED pattern. — a first version still said 1, 2, 3.

pins[] سێ ژمارەی پینەکان هەڵدەگرێت، بۆیە یەک یەک لە دوای یەک سەردانیان دەکات (ڕیزەکەکان). نووسینی سێ بلۆکەکە یەک لە دوای یەکیش کار دەکات. پەیامی سەرەتا دەبێتە Send 1, 2, 3 or 4 to run an LED pattern. — یەکەم وەشانێک هێشتا دەیگوت 1، 2، 3.

Three timing rows from 0 to 1600 ms with an LED picture beside each. Red is HIGH from 300 to 500 ms, yellow from 700 to 900 ms and green from 1100 to 1300 ms: a light running along the three LEDs.سێ ڕیزی کات لە 0 تا 1600 ms، وێنەی LEDـێک لە تەنیشت هەریەکەیان. سوور لە 300 تا 500 ms HIGHـە، زەرد لە 700 تا 900 ms و سەوز لە 1100 تا 1300 ms: ڕووناکییەک کە بە سەر سێ LEDـەکەدا ڕادەکات.
Pattern 4: one flash per LED, one after another.شێوەی 4: یەک ترووسکە بۆ هەر ، یەک لە دوای یەک.CêIT

Lab 4: LED patterns with for loopsتاقیگەی 4: شێوەی LED بە خولی for

While a pattern runs, the board is deafکاتێک شێوەیەک کار دەکات، بۆردەکە گوێی لێ نییە

Type 1 and then, quickly, 3. The green flash comes only when the 4-second red pattern has ended: inside the for loop and its delay() calls the sketch never reaches Serial.read(). The 3 is not lost — it waits in the receive buffer — but it waits 3.3 seconds. This test sketch prints the time at which it reads each command:

1 بنووسە و پاشان بە خێرایی 3. ترووسکەی سەوز تەنیا کاتێک دێت کە شێوە سوورە 4 چرکەییەکە تەواو بووە: لە ناو و بانگکردنەکانی delay()ـدا هەرگیز ناگاتە Serial.read(). 3ـەکە ون نابێت — لە وەرگرتندا چاوەڕێ دەکات — بەڵام ⁦3.3⁩ چرکە چاوەڕێ دەکات. ئەم تاقیکردنەوەیە ئەو کاتە چاپ دەکات کە هەر فەرمانێکی تێدا دەخوێنێتەوە:

A test: when is each command read?تاقیکردنەوە: هەر فەرمانێک کەی دەخوێنرێتەوە؟blocking.inoARDUINORuns on a phone (or an emulator)لەسەر مۆبایل کار دەکات
// While a pattern runs, the board does not read new commands
const int redPin = 2;
const int greenPin = 4;

void setup() {
  Serial.begin(9600);
  pinMode(redPin, OUTPUT);
  pinMode(greenPin, OUTPUT);
}

void loop() {
  if (Serial.available() > 0) {
    char input = Serial.read();
    Serial.print(millis());           // the time now, in ms
    Serial.print(" ms: read ");
    Serial.println(input);

    if (input == '1') {               // 10 blinks = 4 seconds of delay()
      for (int i = 0; i < 10; i++) {
        digitalWrite(redPin, HIGH);
        delay(200);
        digitalWrite(redPin, LOW);
        delay(200);
      }
    } else if (input == '3') {
      digitalWrite(greenPin, HIGH);
      delay(200);
      digitalWrite(greenPin, LOW);
    }
  }
}
Explain the codeڕوونکردنەوەی کۆدەکە
Lineدێڕی 14

millis() is the time since the board started, in ms.

⁦millis()⁩ ئەو کاتەیە کە لە دەستپێکردنی بۆردەکەوە تێپەڕیوە، بە ms.

A timeline from 0 to 5 seconds. Red blinks ten times from 0.3 to 4.3 s under a bar labelled for loop with delay(): 10 blinks, 4 s. A box with 3, typed at 1000 ms, has a dashed arrow labelled waits in the buffer for 3.3 s, ending at 4300 ms, read at 4300 ms; green then flashes at 4.3 s. A Serial Monitor below shows 300 ms: read 1 and 4300 ms: read 3.هێڵێکی کات لە 0 تا 5 چرکە. سوور لە 0.3 تا 4.3 چرکە دە جار دەترووکێت لە ژێر شریتێک بە ناوی خولی for لەگەڵ delay(): 10 ترووسکە، 4 چرکە. خانەیەک بە 3، لە 1000 ms نووسراوە، تیرێکی پچڕپچڕی هەیە بە ناوی 3.3 چرکە لە بافەرەکەدا چاوەڕێ دەکات و لە 4300 msـدا کۆتایی دێت، لە 4300 ms خوێندرایەوە؛ پاشان سەوز لە 4.3 چرکەدا دەترووکێت. Serial Monitor لە خوارەوە 300 ms: read 1 و 4300 ms: read 3 پیشان دەدات.
delay() makes the sketch deaf; commands wait in the buffer.⁦delay()⁩ کەڕ دەکات؛ فەرمانەکان لە چاوەڕێ دەکەن.CêIT

Lab 4: LED patterns with for loopsتاقیگەی 4: شێوەی LED بە خولی for

millis(): check the clock instead of waiting⁦millis()⁩: لەبری چاوەڕێکردن سەیری کاتژمێر بکە

millis() returns the number of milliseconds since the board started. Instead of stopping with delay(), a sketch can look at the clock on every pass of loop() and act only when enough time has passed — the idea of Arduino's Blink Without Delay example. The loop then runs thousands of times a second and can read the Serial Monitor between blinks:

millis() ژمارەی ئەو میلیچرکانە دەگەڕێنێتەوە کە لە دەستپێکردنی بۆردەکەوە تێپەڕیون. لەبری وەستان بە ⁦delay()⁩، دەتوانێت لە هەر جارێکی loop()ـدا سەیری کاتژمێرەکە بکات و تەنیا کاتێک کار بکات کە کاتی پێویست تێپەڕیوە — بیرۆکەی نموونەی Blink Without Delayـی . ئینجا لە چرکەیەکدا هەزاران جار کار دەکات و لە نێوان ترووسکەکاندا دەتوانێت بخوێنێتەوە:

Blink with millis() and keep listeningترووسکاندن بە ⁦millis()⁩ و بەردەوامبوون لە گوێگرتنmillis_demo.inoARDUINORuns on a phone (or an emulator)لەسەر مۆبایل کار دەکات
// Blink with millis(): the board keeps listening while the LED blinks
const int redPin = 2;
const int greenPin = 4;
const unsigned long interval = 500;   // ms between two changes

unsigned long lastChange = 0;         // when the red LED last changed
int redState = LOW;

void setup() {
  Serial.begin(9600);
  pinMode(redPin, OUTPUT);
  pinMode(greenPin, OUTPUT);
}

void loop() {
  unsigned long now = millis();       // look at the clock
  if (now - lastChange >= interval) { // has half a second passed?
    lastChange = now;
    if (redState == LOW) {
      redState = HIGH;
    } else {
      redState = LOW;
    }
    digitalWrite(redPin, redState);
  }

  if (Serial.available() > 0) {       // and, every time, listen
    char input = Serial.read();
    if (input == '3') {
      digitalWrite(greenPin, HIGH);
      Serial.print(now);
      Serial.println(" ms: green on");
    }
  }
}
Explain the codeڕوونکردنەوەی کۆدەکە
Lineدێڕی 4-6

Times are unsigned long, like the value millis() returns.

کاتەکان unsigned longـن، وەک ئەو بەهایەی ⁦millis()⁩ دەیگەڕێنێتەوە.

Lineدێڕی 16-24

Has 500 ms passed since the last change? Then change the red LED and remember the time.

⁦500 ms⁩ لە دوایین گۆڕانەوە تێپەڕیوە؟ ئینجا سوورەکە بگۆڕە و کاتەکە لەبیر بکە.

Lineدێڕی 27-33

Listen on every pass: the 3 is handled at once.

لە هەموو جارێکدا گوێ بگرە: 3 یەکسەر کاری لەسەر دەکرێت.

Keep times in unsigned long variables: millis() goes back to zero after about 50 days (2³² ms ≈ 49.7 days), and the subtraction now - lastChange still gives the right answer across that jump. The same pattern makes the button labs work: debouncing times each press with millis(). The same pattern matters with a watchdog timer: a short loop() that never blocks longer than its time-out (Lab: The Watchdog Timer).

کاتەکان لە unsigned longـدا هەڵبگرە: ⁦millis()⁩ دوای نزیکەی ⁦50⁩ ڕۆژ (⁦2³² ms ≈ 49.7⁩ ڕۆژ) دەگەڕێتەوە بۆ سفر و لێدەرکردنی now - lastChange بە سەر ئەو بازدانەشدا وەڵامی دروست دەدات. هەمان شێوە تاقیگەکانی کارا دەکات: لابردنی هەڵبەزینەوە کاتی هەر پەستانێک بە ⁦millis()⁩ دەپێوێت. هەمان شێوە لەگەڵ گرنگە: loop()ـێکی کورت کە هەرگیز لە سنووری کاتەکەی زیاتر ڕانەوەستێت (تاقیگە: تایمەری پاسەوان).

A timeline from 0 to 2.2 seconds. At the top, many small tick marks show loop() running again and again; each tick asks: now − lastChange ≥ 500? Mostly no, so it goes on at once. The red line changes at 0.5, 1, 1.5 and 2 s, each marked yes: change the red LED. A box with 3, typed at 1000 ms, points up to the green line, which goes HIGH at once at 1 s. A Serial Monitor shows 1000 ms: green on.هێڵێکی کات لە 0 تا 2.2 چرکە. لە سەرەوە زۆر نیشانەی بچووک پیشان دەدەن کە loop() دووپاتە و دووپاتە کار دەکات؛ هەر نیشانەیەک دەپرسێت: now − lastChange ≥ 500؟ زۆربەی جار نەخێر، بۆیە یەکسەر بەردەوام دەبێت. هێڵی سوور لە 0.5، 1، 1.5 و 2 چرکەدا دەگۆڕێت، هەریەکە بە نیشانەی بەڵێ: LEDـە سوورەکە بگۆڕە. خانەیەک بە 3، لە 1000 ms نووسراوە، بەرەو هێڵی سەوز ئاماژە دەکات، کە لە 1 چرکەدا یەکسەر دەبێتە HIGH. Serial Monitor دەقی 1000 ms: green on پیشان دەدات.
millis(): the loop keeps running, so it can react at once.⁦millis()⁩: بەردەوام کار دەکات، بۆیە دەتوانێت یەکسەر وەڵام بداتەوە.CêIT

Lab 5: toggles with switch and !تاقیگەی 5: گۆڕین بە switch و !

Lab 5 switches each LED on with one press of its letter and off with the next. It keeps three boolean variables, redOn, yellowOn and greenOn (true or false). ! is logical not: redOn = !redOn; turns true into false and false into true (Two conditions at once: &&, || and !). digitalWrite(redPin, redOn) works because true counts as HIGH and false as LOW.

تاقیگەی 5 بە یەک داگرتنی پیتی هەر هەڵی دەکات و بە داگرتنی دواتر دەیکوژێنێتەوە. سێ هەڵدەگرێت، redOn، yellowOn و greenOn (true یان false). ! واتە نای لۆجیکی: redOn = !redOn; true دەکاتە false و false دەکاتە true (دوو مەرج پێکەوە: &&، ⁦||⁩ و !). digitalWrite(redPin, redOn) کار دەکات چونکە true وەک HIGH و false وەک LOW هەژمار دەکرێت.

switch (input) jumps to the case that matches the letter, and break ends that case; a letter with no case does nothing (The switch statement).

switch (input) باز دەداتە ئەو caseـەی لەگەڵ پیتەکە یەک دەگرێتەوە و break ئەو caseـە کۆتایی پێ دەهێنێت؛ پیتێک کە caseـی نەبێت هیچ ناکات (ڕستەی switch).

Lab 5, correctedتاقیگەی 5، چاککراوtoggles_fixed.inoARDUINORuns on a phone (or an emulator)لەسەر مۆبایل کار دەکات
// Lab 5: toggle each LED with one letter
const int redPin = 2;
const int yellowPin = 3;
const int greenPin = 4;

bool redOn = false;                   // remember the state of each LED
bool yellowOn = false;
bool greenOn = false;

void setup() {
  Serial.begin(9600);
  pinMode(redPin, OUTPUT);
  pinMode(yellowPin, OUTPUT);
  pinMode(greenPin, OUTPUT);
  Serial.println("R: toggle red, Y: toggle yellow, G: toggle green");
}

void loop() {
  if (Serial.available() > 0) {
    char input = Serial.read();
    if (input == '\n' || input == '\r') {
      return;                         // ignore the Enter key
    }

    switch (input) {
      case 'R':
        redOn = !redOn;               // true -> false, false -> true
        digitalWrite(redPin, redOn);
        break;
      case 'Y':
        yellowOn = !yellowOn;
        digitalWrite(yellowPin, yellowOn);
        break;
      case 'G':
        greenOn = !greenOn;
        digitalWrite(greenPin, greenOn);
        break;
    }

    Serial.print("Red: ");
    Serial.print(redOn);
    Serial.print(", Yellow: ");
    Serial.print(yellowOn);
    Serial.print(", Green: ");
    Serial.println(greenOn);          // println ends the status line
  }
}
Explain the codeڕوونکردنەوەی کۆدەکە
Lineدێڕی 6-8

The state of each LED, remembered between commands.

دۆخی هەر ، لە نێوان فەرمانەکاندا لەبیر دەکرێت.

Lineدێڕی 21-23

The Enter key is ignored, so each command prints one status line.

Enter پشتگوێ دەخرێت، بۆیە هەر فەرمانێک یەک دێڕی دۆخ چاپ دەکات.

Lineدێڕی 45

println ends the status line.

println دێڕی دۆخەکە کۆتایی پێ دەهێنێت.

switch (input) at the top branches to three boxes: case 'R': redOn = !redOn; break; case 'Y': yellowOn = !yellowOn; break; case 'G': greenOn = !greenOn; break; and a dashed branch to any other letter: no case matches, nothing happens. All paths join and lead to: print the status line, then println. Note: !true is false and !false is true, so each R switches red on, off, on.switch (input) لە سەرەوە دابەش دەبێت بۆ سێ خانە: case 'R': redOn = !redOn; break; case 'Y': yellowOn = !yellowOn; break; case 'G': greenOn = !greenOn; break; و لقێکی پچڕپچڕ بۆ هەر پیتێکی تر: هیچ case یەک ناگرێتەوە، هیچ ڕوو نادات. هەموو ڕێگاکان پێکەوە دەگەنە: دێڕی دۆخ چاپ بکە، پاشان println. تێبینی: نیشانەی ! بەهای true دەکاتە false و false دەکاتە true، بۆیە هەر Rـێک سوور هەڵدەکات، دەیکوژێنێتەوە، هەڵی دەکات.
switch picks one case; ! flips the stored state.switch یەک case هەڵدەبژێرێت؛ ! دۆخی هەڵگیراو پێچەوانە دەکاتەوە.CêIT

Lab 5: toggles with switch and !تاقیگەی 5: گۆڕین بە switch و !

Common mistake: one endless lineهەڵەی باو: یەک دێڕی بێکۆتایی

Two Serial Monitor panes. Top, the first version, where the last call is print: after the start message, Red: 1, Yellow: 0, Green: 0 is repeated without line breaks, so all statuses run together on one long line. Bottom, fixed with println at the end and the Enter key ignored: the start message and then one status per line: Red: 1, Yellow: 0, Green: 0; Red: 1, Yellow: 1, Green: 0; Red: 0, Yellow: 1, Green: 0; Red: 0, Yellow: 1, Green: 1.دوو بەشی Serial Monitor. سەرەوە، یەکەم وەشان، کە دوایین بانگکردن printـە: دوای پەیامی سەرەتا، Red: 1, Yellow: 0, Green: 0 بێ دێڕشکاندن دووپاتە دەبێتەوە، بۆیە هەموو دۆخەکان لەسەر یەک دێڕی درێژ تێکەڵ دەبن. خوارەوە، چاککراو بە println لە کۆتاییدا و پشتگوێخستنی دوگمەی Enter: پەیامی سەرەتا و پاشان هەر دۆخێک لەسەر دێڕێک: Red: 1, Yellow: 0, Green: 0؛ Red: 1, Yellow: 1, Green: 0؛ Red: 0, Yellow: 1, Green: 0؛ Red: 0, Yellow: 1, Green: 1.
Before and after: one println makes the status readable.پێش و دوا: یەک println دۆخەکە خوێندراو دەکات.CêIT

Lab 5: toggles with switch and !تاقیگەی 5: گۆڕین بە switch و !

Task 5: A for all on, O for all offئەرکی ⁦5: A⁩ بۆ هەمووی هەڵکراو، O بۆ هەمووی کوژاو

ExerciseڕاهێنانTask 5ئەرکی 5

Add two commands to Lab 5: A switches all three LEDs on and O switches them all off. The status line must stay correct, and the start message should mention A and O.

دوو فەرمان بۆ تاقیگەی 5 زیاد بکە: A هەر سێ هەڵدەکات و O هەموویان دەکوژێنێتەوە. دێڕی دۆخ دەبێت دروست بمێنێتەوە و پەیامی سەرەتا دەبێت A و O بڵێت.

Hintئاماژە

Two more cases; in each, set all three booleans.

دوو caseـی زیاتر؛ لە هەریەکەیاندا هەر سێ دیاری بکە.

Show answerوەڵامەکە پیشان بدە
Task 5ئەرکی 5task5_fixed.inoARDUINORuns on a phone (or an emulator)لەسەر مۆبایل کار دەکات
// Task 5: Lab 5 plus A (all on) and O (all off)
const int redPin = 2;
const int yellowPin = 3;
const int greenPin = 4;

bool redOn = false;
bool yellowOn = false;
bool greenOn = false;

void setup() {
  Serial.begin(9600);
  pinMode(redPin, OUTPUT);
  pinMode(yellowPin, OUTPUT);
  pinMode(greenPin, OUTPUT);
  Serial.println("R, Y, G: toggle one LED. A: all on. O: all off.");
}

void loop() {
  if (Serial.available() > 0) {
    char input = Serial.read();
    if (input == '\n' || input == '\r') {
      return;
    }

    switch (input) {
      case 'R':
        redOn = !redOn;
        break;
      case 'Y':
        yellowOn = !yellowOn;
        break;
      case 'G':
        greenOn = !greenOn;
        break;
      case 'A':                       // all on
        redOn = true;
        yellowOn = true;
        greenOn = true;
        break;
      case 'O':                       // all off
        redOn = false;
        yellowOn = false;
        greenOn = false;
        break;
    }
    digitalWrite(redPin, redOn);      // write all three after the switch
    digitalWrite(yellowPin, yellowOn);
    digitalWrite(greenPin, greenOn);

    Serial.print("Red: ");
    Serial.print(redOn);
    Serial.print(", Yellow: ");
    Serial.print(yellowOn);
    Serial.print(", Green: ");
    Serial.println(greenOn);
  }
}
Explain the codeڕوونکردنەوەی کۆدەکە
Lineدێڕی 35-44

A and O set all three states.

A و O هەر سێ دۆخەکە دیاری دەکەن.

Lineدێڕی 46-48

Write the three pins once, after the switch, from the stored states.

سێ پینەکە یەک جار، دوای switch، لە دۆخە هەڵگیراوەکانەوە بنووسە.

Writing the pins after the switch keeps the LEDs and the printed states in step. A first version of Task 5 had the same missing println, and its start message did not mention A and O.

نووسینی پینەکان دوای switch، و دۆخە چاپکراوەکان پێکەوە ڕێک دەهێڵێتەوە. یەکەم وەشانی ئەرکی 5 هەمان printlnـی ونی هەبوو و پەیامی سەرەتاکەی باسی A و Oـی نەدەکرد.

A password over Serialتێپەڕەوشەیەک بە Serial

The last sketch of this lab checks a password typed in the Serial Monitor: the green LED for the right one, the red LED for a wrong one. It reads a whole line with Serial.readStringUntil('\n'), which collects the characters up to the newline and drops the newline, and trim() removes spaces and a leftover '\r'. The next lab opens a lock with buttons instead of the keyboard, and cleans every press first with debouncing.

دوایین ئەم تاقیگەیە دەپشکنێت کە لە دەنووسرێت: سەوز بۆ دروست و سوور بۆ هەڵە. بە Serial.readStringUntil('\n') دێڕێکی تەواو دەخوێنێتەوە، کە تا کۆ دەکاتەوە و ئەو فڕێ دەدات و trim() بۆشاییەکان و '\r'ـێکی بەجێماو لادەبات. تاقیگەی داهاتوو قفڵێک بە لەبری دەکاتەوە و هەموو پەستانێک سەرەتا بە لابردنی هەڵبەزینەوە پاک دەکاتەوە.

The serial password check (practice only)پشکنینی تێپەڕەوشە بە Serial (تەنیا بۆ ڕاهێنان)password_fixed.inoARDUINORuns on a phone (or an emulator)لەسەر مۆبایل کار دەکات
// The serial password check (practice only: read the security note)
const int redPin = 2;
const int greenPin = 4;
const String password = "test";       // a password inside the code!

void setup() {
  Serial.begin(9600);
  pinMode(redPin, OUTPUT);
  pinMode(greenPin, OUTPUT);
  Serial.println("Enter the password:");
}

void loop() {
  if (Serial.available() > 0) {
    String userInput = Serial.readStringUntil('\n');  // read up to Enter
    userInput.trim();                                   // remove spaces and \r
    if (userInput == password) {
      digitalWrite(redPin, LOW);
      digitalWrite(greenPin, HIGH);
      Serial.println("Access granted");
    } else {
      digitalWrite(redPin, HIGH);
      digitalWrite(greenPin, LOW);
      Serial.println("Access denied");
    }
  }
}
Explain the codeڕوونکردنەوەی کۆدەکە
Lineدێڕی 4

A password written in the code: fine for this exercise, never for a real device.

کە لە ناو کۆددا نووسراوە: بۆ ئەم ڕاهێنانە باشە، هەرگیز بۆ ئامێرێکی ڕاستەقینە.

Lineدێڕی 15-16

Read up to Enter, then remove spaces and \r.

تا Enter بخوێنەرەوە، پاشان بۆشایی و \r لاببە.

The bytes t, e, s, t, \r and \n (typed test + Enter with Both NL & CR) go into readStringUntil('\n'), which gives "test\r"; trim() turns it into "test"; a decision == password? leads to Access granted with a green LED (yes) or Access denied with a red LED (no). Note: trim() removes spaces and the \r that Both NL & CR leaves.بایتەکانی t، e، s، t، \r و \n (test + Enter بە Both NL & CR نووسراوە) دەچنە readStringUntil('\n')، کە "test\r" دەدات؛ trim() دەیکاتە "test"؛ بڕیاری == password? دەچێتە Access granted لەگەڵ LEDـێکی سەوز (بەڵێ) یان Access denied لەگەڵ LEDـێکی سوور (نەخێر). تێبینی: trim() بۆشاییەکان و ئەو \rـە لادەبات کە Both NL & CR بەجێی دەهێڵێت.
Reading and cleaning a whole line before comparing it.خوێندنەوە و پاککردنەوەی دێڕێکی تەواو پێش بەراوردکردنی.CêIT

A password over Serialتێپەڕەوشەیەک بە Serial

Security: never ship a password inside the codeئاسایش: هەرگیز ئامێرێک بە تێپەڕەوشەیەک لە ناو کۆددا مەنێرە بازاڕ

This lab is fine for practice, but a real device must never work like this. The password "test" is written in the code, so it ends up in the firmware: anyone who can read the board's flash or a copy of the firmware file can find it (picture), and every board built from the same code shares it. Such hard-coded credentials and default passwords are how the Mirai malware took over cameras and routers in 2016: it simply tried 62 default username-and-password pairs (Mirai).

ئەم تاقیگەیە بۆ ڕاهێنان باشە، بەڵام ئامێرێکی ڕاستەقینە هەرگیز نابێت بەم شێوەیە کار بکات. "test" لە ناو کۆددا نووسراوە، بۆیە دەچێتە ناو : هەر کەسێک بتوانێت فلاشی بۆردەکە یان کۆپییەکی بخوێنێتەوە دەتوانێت بیدۆزێتەوە (وێنەکە) و هەموو ئەو بۆردانەی لە هەمان کۆد دروست کراون هەمان هەیە. ئەم جۆرە و ئەو ڕێگایە بوون کە Mirai لە ساڵی ⁦2016⁩ـدا کامێرا و ڕاوتەری پێ داگیر کرد: تەنیا ⁦62⁩ جووتی بنەڕەتیی و تاقی دەکردەوە (Mirai).

The European standard ETSI EN 303 645 for consumer IoT devices forbids universal default passwords. Good practice is a unique password for each device, set by its owner and stored hashed with a salt, a pause after several wrong tries, and security updates (Passwords, MFA and Access Control, Unique passwords, and no secrets in the code).

ستانداردی ئەورووپیی ⁦ETSI EN 303 645⁩ بۆ ئامێرەکانی IoTـی بەکارهێنەران گشتی قەدەغە دەکات. کاری باش تایبەتە بۆ هەر ئامێرێک، کە خاوەنەکەی دایدەنێت و بە و هەڵدەگیرێت، وەستانێک دوای چەند هەوڵێکی هەڵە و نوێکردنەوەی ئاسایش (تێپەڕەوشەکان، MFA و کۆنترۆڵی دەستڕاگەیشتن، تێپەڕەوشەکانی تایبەت و هیچ نهێنییەک لە ناو کۆددا).

Left: the line const String password = "test"; goes through compile and upload into the firmware bytes in flash, shown as rows of hexadecimal numbers; the bytes 74 65 73 74 are highlighted: they are "test" in ASCII. Right, a green panel, better for a real device: a different password for every device, never a shared default; set by the owner at first start, not written in the code; stored as a salted hash, never as plain text; a pause after several wrong tries; updates when weaknesses are found. Bottom: ETSI EN 303 645, no universal default passwords.لای چەپ: دێڕی const String password = "test"; بە کۆمپایل و هەڵبارکردندا دەچێتە ناو بایتەکانی پتەوواڵە لە فلاشدا، کە وەک ڕیزی ژمارەی شانزەیی پیشان دراون؛ بایتەکانی 74 65 73 74 دیاری کراون: بە ASCII دەکەنە "test". ڕاست، خانەیەکی سەوز، باشتر بۆ ئامێرێکی ڕاستەقینە: تێپەڕەوشەیەکی جیاواز بۆ هەر ئامێرێک، هەرگیز تێپەڕەوشەی بنەڕەتییەکی هاوبەش؛ خاوەنەکە لە یەکەم هەڵکردندا دایدەنێت، نەک لە ناو کۆددا بنووسرێت؛ بە کرداری هاش و خوێ هەڵدەگیرێت، هەرگیز وەک دەقی ئاسایی؛ وەستانێک دوای چەند هەوڵێکی هەڵە؛ نوێکردنەوە کاتێک لاوازی دەدۆزرێتەوە. خوارەوە: ETSI EN 303 645، هیچ تێپەڕەوشەی بنەڕەتییەکی گشتی نابێت.
A password in the code ends up readable in the firmware (an illustration of flash bytes). لە ناو کۆددا لە دەخوێنرێتەوە (وێنەیەکی فلاش بۆ ڕوونکردنەوە).CêIT

Common mistakesهەڵە باوەکان

MistakeهەڵەBetterباشتر
Strange symbols in the Serial Monitor.هێمای سەیر لە .Set the monitor's baud menu to the speed in Serial.begin(). baudـی Serial Monitor لەسەر خێرایی ناو ⁦Serial.begin()⁩ دابنێ.
Calling Serial.read() without asking first.بانگکردنی ⁦Serial.read()⁩ بێ پرسینی پێشوەختە.Check Serial.available() > 0; read() returns −1 when nothing waits.Serial.available() > 0 بپشکنە؛ ⁦read()⁩ کاتێک هیچ چاوەڕێ نەبێت ⁦−1⁩ دەگەڕێنێتەوە.
The Enter key arrives as a command. Enter وەک فەرمان دەگات.Ignore '\n' and '\r' in the sketch (or choose No Line Ending).لە '\n' و '\r' پشتگوێ بخە (یان No Line Ending هەڵبژێرە).
A copied branch writes the same pin twice.بەشێکی کۆپیکراو هەمان پین دوو جار دەنووسێت.Write all three pins in every branch, in the same order.لە هەموو بەشێکدا هەر سێ پینەکە بە هەمان ڕیز بنووسە.
Statuses run together on one line.دۆخەکان لەسەر یەک دێڕ تێکەڵ دەبن.End each line with println().هەر دێڕێک بە ⁦println()⁩ کۆتایی پێ بهێنە.
command == "R" with double quotes.command == "R" بە .A char needs single quotes, 'R'. "R" is a string, so the test can never be true: most boards stop with a compile error, while the UNO R3 only shows a warning.char دەوێت، 'R'. "R" ، بۆیە تاقیکردنەوەکە هەرگیز ڕاست نابێت: زۆربەی بۆردەکان بە هەڵەی کۆمپایل دەوەستن، بەڵام ⁦UNO R3⁩ تەنیا ئاگادارکردنەوەیەک پیشان دەدات.
A missing break in a switch.breakـێکی ون لە switchـدا.Without break the next case runs too (Forgetting break).بێ break، caseـی دواتریش جێبەجێ دەبێت (لەبیرکردنی break).
Long patterns with delay() make the board deaf.شێوەی درێژ بە ⁦delay()⁩ بۆردەکە کەڕ دەکەن.Use millis() to check the clock and keep listening.⁦millis()⁩ بەکار بهێنە بۆ پشکنینی کاتژمێر و بەردەوامبوون لە گوێگرتن.
A password written in the code. کە لە ناو کۆددا نووسراوە.Practice only; a real device needs a unique password set by its owner.تەنیا بۆ ڕاهێنان؛ ئامێری ڕاستەقینە تایبەتی دەوێت کە خاوەنەکەی دایدەنێت.

Exercisesڕاهێنانەکان

ExerciseڕاهێنانHow long does a line take?دێڕێک چەند دەخایەنێت؟

The board sends Serial.println("Hello, Aram!") at 9600 baud. That is 12 characters plus \r\n. How long does the line take on the wire, and how long at 115200 baud?

بۆردەکە Serial.println("Hello, Aram!") بە ⁦9600 baud⁩ دەنێرێت. ئەمە ⁦12⁩ لەگەڵ \r\n. دێڕەکە لەسەر وایەرەکە چەند دەخایەنێت و بە ⁦115200 baud⁩ چەند؟

Show answerوەڵامەکە پیشان بدە
t=14×10 bits9600 bits/s≈14.6 ms,140115200≈1.2 mst = \frac{14 \times 10\text{ bits}}{9600\text{ bits/s}} \approx 14.6\text{ ms}, \qquad \frac{140}{115200} \approx 1.2\text{ ms}

14 bytes of 10 bits each. At 115200 baud the same line takes about twelve times less time.

⁦14⁩ ، هەریەکە ⁦10⁩ . بە ⁦115200 baud⁩ هەمان دێڕ نزیکەی دوازدە جار کەمتر دەخایەنێت.

ExerciseڕاهێنانCount the commandsفەرمانەکان بژمێرە

Change Lab 3 so that after each valid command it prints how many valid commands it has received so far. Unknown letters must not be counted.

تاقیگەی 3 بگۆڕە بۆ ئەوەی دوای هەر فەرمانێکی دروست چاپ بکات تا ئێستا چەند فەرمانی دروستی وەرگرتووە. پیتە نەناسراوەکان نابێت بژمێردرێن.

Hintئاماژە

Declare int commands = 0; above setup().

int commands = 0; لە سەرووی ⁦setup()⁩ بناسێنە.

Show answerوەڵامەکە پیشان بدە
Lab 3 with a command counterتاقیگەی 3 لەگەڵ ژمێرەری فەرمانcount.inoARDUINORuns on a phone (or an emulator)لەسەر مۆبایل کار دەکات
// Lab 3 with a command counter
const int redPin = 2;
const int yellowPin = 3;
const int greenPin = 4;

int commands = 0;                   // how many valid commands so far

void setup() {
  Serial.begin(9600);
  pinMode(redPin, OUTPUT);
  pinMode(yellowPin, OUTPUT);
  pinMode(greenPin, OUTPUT);
}

void loop() {
  if (Serial.available() > 0) {
    char command = Serial.read();
    if (command == '\n' || command == '\r') {
      return;
    }
    if (command == 'R' || command == 'Y' || command == 'G' || command == 'O') {
      digitalWrite(redPin, command == 'R');      // true -> HIGH, false -> LOW
      digitalWrite(yellowPin, command == 'Y');
      digitalWrite(greenPin, command == 'G');
      commands = commands + 1;
      Serial.print("Commands so far: ");
      Serial.println(commands);
    } else {
      Serial.println("Use R, Y, G or O.");
    }
  }
}
Explain the codeڕوونکردنەوەی کۆدەکە
Lineدێڕی 6

A global variable keeps its value between passes of loop().

گشتی بەهاکەی لە نێوان جارەکانی ⁦loop()⁩ـدا دەپارێزێت.

Lineدێڕی 22-24

command == 'R' is true or false, which digitalWrite() takes as HIGH or LOW.

command == 'R' ڕاست یان هەڵەیە، کە ⁦digitalWrite()⁩ وەک HIGH یان LOW وەریدەگرێت.

ExerciseڕاهێنانThree triesسێ هەوڵ

Change the password check so that after three wrong passwords it stops checking and prints "Locked" until the board is reset. Is the device now safe?

پشکنینی بگۆڕە بۆ ئەوەی دوای سێ تێپەڕەوشەی هەڵە پشکنین ڕابگرێت و تا بۆردەکە Reset دەکرێت ⁦"Locked"⁩ چاپ بکات. ئایا ئێستا ئامێرەکە سەلامەتە؟

Show answerوەڵامەکە پیشان بدە
Locked after three wrong triesدوای سێ هەوڵی هەڵە قفڵ دەبێتthree_tries.inoARDUINORuns on a phone (or an emulator)لەسەر مۆبایل کار دەکات
// Password check that locks after three wrong tries (still practice only)
const int redPin = 2;
const int greenPin = 4;
const String password = "test";
int wrongTries = 0;

void setup() {
  Serial.begin(9600);
  pinMode(redPin, OUTPUT);
  pinMode(greenPin, OUTPUT);
  Serial.println("Enter the password:");
}

void loop() {
  if (Serial.available() > 0) {
    String userInput = Serial.readStringUntil('\n');
    userInput.trim();
    if (wrongTries >= 3) {
      Serial.println("Locked. Reset the board to try again.");
    } else if (userInput == password) {
      digitalWrite(redPin, LOW);
      digitalWrite(greenPin, HIGH);
      wrongTries = 0;
      Serial.println("Access granted");
    } else {
      digitalWrite(redPin, HIGH);
      digitalWrite(greenPin, LOW);
      wrongTries = wrongTries + 1;
      Serial.print("Access denied (");
      Serial.print(wrongTries);
      Serial.println(" of 3)");
    }
  }
}

It is better — guessing is slow now — but still not safe: the password is still in the code, it is the same on every board, and anyone can reset the board and guess again.

باشترە — ئێستا تاقیکردنەوەی هێواشە — بەڵام هێشتا سەلامەت نییە: هێشتا لە ناو کۆددایە، لەسەر هەموو بۆردێک هەمانە و هەر کەسێک دەتوانێت بۆردەکە Reset بکات و دووپاتە تاقی بکاتەوە.

ExerciseڕاهێنانWhich line ending?کام کۆتایی دێڕ؟

A sketch reads whole lines with readStringUntil('\n') and then calls trim(). With which line-ending settings does it answer at once, and with which does it wait one second?

بە readStringUntil('\n') دێڕی تەواو دەخوێنێتەوە و پاشان trim() بانگ دەکات. بە کام ڕێکخستنی کۆتایی دێڕ یەکسەر وەڵام دەداتەوە و بە کامیان یەک چرکە چاوەڕێ دەکات؟

Show answerوەڵامەکە پیشان بدە

New Line and Both NL & CR answer at once: the '\n' ends the read, and trim() removes the '\r'. With Carriage Return or No Line Ending no '\n' arrives, so the read ends only at its 1-second timeout; the text still arrives, a second late (the checker answered at 1500 ms for a password sent at 500 ms).

New Line و ⁦Both NL & CR⁩ یەکسەر وەڵام دەدەنەوە: '\n' خوێندنەوەکە کۆتایی پێ دەهێنێت و ⁦trim()⁩ '\r' لادەبات. بە Carriage Return یان No Line Ending هیچ '\n'ـێک ناگات، بۆیە خوێندنەوەکە تەنیا دوای 1 چرکە ⁦(timeout)⁩ کۆتایی دێت؛ دەقەکە هەر دەگات، بەڵام چرکەیەک درەنگ (پشکنەرەکە بۆ کە لە ⁦500 ms⁩ نێردرابوو لە ⁦1500 ms⁩ـدا وەڵامی دایەوە).

Summaryپوختە

  • Serial.begin(9600) opens serial communication at 9600 baud; the Serial Monitor's baud menu must match. One character costs 10 bits, so 9600 baud ≈ 960 characters a second.
  • print() continues the line; println() ends it with \r\n.
  • Incoming bytes wait in a 64-byte buffer: check Serial.available(), then Serial.read() one character, or readStringUntil('\n') a whole line.
  • Enter adds the chosen line ending (New Line '\n' by default), and a sketch that reads characters receives it too: ignore '\n' and '\r'.
  • if/else and switch choose what to do; || means or; ! flips a boolean; for repeats a pattern.
  • delay() makes the sketch deaf; millis() lets it keep listening.
  • Never ship a device with a password written in its code.
  • ⁦Serial.begin(9600)⁩ بە ⁦9600 baud⁩ دەکاتەوە؛ baudـی Serial Monitor دەبێت یەک بگرێتەوە. هەر ⁦10⁩ دەخایەنێت، بۆیە ⁦9600 baud ≈ 960⁩ لە چرکەیەکدا.
  • ⁦print()⁩ دێڕەکە بەردەوام دەکات؛ ⁦println()⁩ بە \r\n کۆتایی پێ دەهێنێت.
  • هاتووەکان لە ⁦64⁩ بایتیدا چاوەڕێ دەکەن: ⁦Serial.available()⁩ بپشکنە، پاشان ⁦Serial.read()⁩ بۆ یەک ، یان readStringUntil('\n') بۆ دێڕێکی تەواو.
  • Enter کۆتایی دێڕی هەڵبژێردراو زیاد دەکات (بە بنەڕەت New Line، واتە '\n') و کە دەخوێنێتەوە ئەویش وەردەگرێت: '\n' و '\r' پشتگوێ بخە.
  • ⁦if/else⁩ و switch هەڵدەبژێرن چی بکرێت؛ ⁦||⁩ واتە یان؛ ! پێچەوانە دەکاتەوە؛ for شێوەیەک دووپاتە دەکاتەوە.
  • ⁦delay()⁩ کەڕ دەکات؛ ⁦millis()⁩ ڕێگەی پێ دەدات بەردەوام گوێ بگرێت.
  • هەرگیز ئامێرێک بە کە لە ناو کۆدەکەیدا نووسراوە مەنێرە بازاڕ.
Review questionsپرسیارەکانی پێداچوونەوە
Why does the Serial Monitor show strange symbols?بۆچی Serial Monitor هێمای سەیر پیشان دەدات؟

Its baud rate does not match the one in Serial.begin().

لەگەڵ ئەوەی ناو ⁦Serial.begin()⁩ یەک ناگرێتەوە.

What does the board receive when you type R and press Enter with New Line?کاتێک R دەنووسیت و بە New Line دوگمەی Enter دادەگریت بۆردەکە چی وەردەگرێت؟

Two bytes: 'R' (82) and '\n' (10).

دوو : 'R' ⁦(82)⁩ و '\n' ⁦(10)⁩.

Which two mistakes did Lab 3 have?تاقیگەی 3 کام دوو هەڵەی هەبوو؟

The G and O branches switched red off twice instead of yellow, and the Enter key's '\n' was treated as a command.

بەشەکانی G و O لەبری زەرد دوو جار سووریان دەکوژاندەوە و '\n'ـی Enter وەک فەرمان مامەڵەی لەگەڵ دەکرا.

Lesson complete!وانەکە تەواو بوو!

Well done. Review the key terms, then go on to the next lesson.دەستخۆش. سەیرێکی زاراوە سەرەکییەکان بکەرەوە، پاشان بڕۆ بۆ وانەی داهاتوو.

Key termsزاراوە سەرەکییەکان

Next lessonوانەی داهاتوو

Lab: Buttons, INPUT_PULLUP and Debouncingتاقیگە: دوگمەکانی پەستان، ⁦INPUT_PULLUP⁩ و لابردنی هەڵبەزینەوە

References and further readingسەرچاوەکان و خوێندنەوەی زیاتر

This lecture is a first edition. The Kurdish text and terminology are waiting for review by Kurdish IT teachers.ئەم وانەیە چاپی یەکەمە. دەقە کوردییەکە و زاراوەکانی چاوەڕێی پێداچوونەوەی مامۆستایانی کوردی بواری IT ن.

Appearanceڕووکار

Modeدۆخ
Styleشێواز
Coloursڕەنگەکان

Saved on this device only.تەنیا لەسەر ئەم ئامێرە پاشەکەوت دەکرێت.