0Pricing
Arduino & IoT Academy · Lekcja

Serial.print kontra println

Wysyłanie opisanych wartości do monitora portu szeregowego

Serial.print kontra println to bezpłatna lekcja Arduino & IoT Academy na CoddyKit. To lekcja 2 z 4. Możesz przeczytać całą lekcję poniżej za darmo — a potem ćwiczyć ją interaktywnie w przeglądarce z wbudowanym edytorem kodu i tutorem AI dostępnym 24/7. To część ścieżki edukacyjnej Arduino & IoT Academy, a Twój postęp synchronizuje się między webem a aplikacją CoddyKit. Kurs Arduino & IoT Academy zawiera 4 lekcji w sumie.

Części tej lekcji nie zostały jeszcze przetłumaczone i są wyświetlane po angielsku.

Sending Words Out

Once the channel is open, you send text with Serial.print(). Whatever you pass shows up in the Serial Monitor on your computer.

Serial.print("Hello");

Print Stays on One Line

The key thing about Serial.print() is that it does not move to a new line. The next print appears right after it.

Serial.print("Hi");
Serial.print("There");

That Prints HiThere

Those two prints produce HiThere, jammed together with no gap. Print never adds spacing for you.

Meet println

Use Serial.println() when you want each message on its own line. The ln means it adds a line break at the end.

Serial.println("Line one");
Serial.println("Line two");

Clean, Readable Output

That gives you two tidy rows in the Monitor. println is your go-to for status messages you read top to bottom.

Printing Numbers

You are not limited to text. Pass a number and Serial.print() converts it to readable digits automatically.

int score = 42;
Serial.println(score);

Build a Label

Mix text and values for clarity. Print the label first, then print the number, so output reads like a sentence.

Serial.print("Score: ");
Serial.println(score);

Why Labels Help

A bare number like 42 means nothing later. A label like Score: 42 tells you exactly what you are looking at.

Print Inside loop

Calls to print and println usually live in loop(), so values keep streaming out as your program runs.

void loop() {
  Serial.println("running");
}

A Common Pattern

A neat habit: print the label, then println the value. The label glues to the number, then the line wraps cleanly.

Serial.print("Temp: ");
Serial.println(24);

Pick the Right One

Reach for print when more output follows on the same line, and println when this is the end of the line. 🙂

Quick Check

Which call ends the current line and moves output to the next row?

Recap

You learned that print keeps output on one line while println adds a break, and that labeling values makes your Monitor easy to read. 🎉

Często zadawane pytania

Czy lekcja „Serial.print kontra println” jest bezpłatna?

Tak — pełny tekst „Serial.print kontra println” jest dostępny za darmo tutaj w sieci. Aby ćwiczyć ją interaktywnie (wbudowany edytor kodu i tutor AI dostępny 24/7) i odblokować resztę kursu Arduino & IoT Academy, przejdź na CoddyKit PRO. Kurs Arduino & IoT Academy zawiera 4 lekcji w sumie.

Co nauczysz się w „Serial.print kontra println”?

Wysyłanie opisanych wartości do monitora portu szeregowego Ćwiczysz Arduino & IoT Academy z praktycznym kodem, który uruchamiasz bezpośrednio w przeglądarce, a tutor AI dostępny 24/7 odpowiada na Twoje pytania podczas pracy nad lekcją.

Czy potrzebuję doświadczenia, aby zacząć Arduino & IoT Academy?

Nie wymagamy żadnego doświadczenia. Arduino & IoT Academy w CoddyKit jest strukturyzowany dla początkujących i zaawansowanych użytkowników, więc możesz zacząć tutaj lub od początku i uczyć się w swoim tempie. To lekcja 2 z 4.

Ile czasu zajmuje lekcja „Serial.print kontra println”?

Większość lekcji CoddyKit trwa około 5–10 minut. Każda lekcja to mały, interaktywny krok, dzięki czemu robisz systematyczne postępy i zawsze wracasz dokładnie do tego samego miejsca — na webie i w aplikacji.

Czy mogę pisać i uruchamiać kod w tej lekcji Arduino & IoT Academy?

Tak. Każda lekcja Arduino & IoT Academy zawiera wbudowany edytor kodu, więc piszesz i uruchamiasz prawdziwy kod bezpośrednio w przeglądarce i od razu otrzymujesz sprzężenie zwrotne od AI — bez konfiguracji na komputerze.

Wszystkie lekcje w tym kursie

  1. Serial.begin i szybkość transmisji
  2. Serial.print kontra println
  3. Obserwowanie wartości czujników na żywo
  4. Odczytywanie wpisywanych poleceń
← Powrót do Arduino & IoT Academy