Serial.print e println
Inviare valori con etichette al Monitor seriale
Serial.print e println è una lezione Arduino & IoT Academy gratuita su CoddyKit. Questa è la lezione 2 di 4. Puoi leggere la lezione completa qui gratuitamente — poi esercitati direttamente nel browser con un editor di codice integrato e un tutor IA disponibile 24/7. Fa parte del percorso di apprendimento Arduino & IoT Academy, e i tuoi progressi si sincronizzano tra il web e l'app CoddyKit. Il corso Arduino & IoT Academy include 4 lezioni in totale.
Parti di questa lezione non sono ancora state tradotte e vengono mostrate in inglese.
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. 🎉
Domande Frequenti
La lezione «Serial.print e println» è gratuita?
Sì — il testo completo di «Serial.print e println» è gratuito qui sul web. Per esercitarvi in modo interattivo (un editor di codice integrato e un tutor IA 24/7) e sbloccare il resto del corso Arduino & IoT Academy, passa a CoddyKit PRO. Il corso Arduino & IoT Academy include 4 lezioni in totale.
Cosa imparerò in «Serial.print e println»?
Inviare valori con etichette al Monitor seriale Eserciti Arduino & IoT Academy con codice pratico che esegui direttamente nel browser, e un tutor IA 24/7 risponde alle tue domande mentre lavori sulla lezione.
Ho bisogno di esperienza per iniziare Arduino & IoT Academy?
Non è richiesta alcuna esperienza precedente. Arduino & IoT Academy su CoddyKit è strutturato per principianti e studenti avanzati, quindi puoi iniziare da qui o dall'inizio e procedere al tuo ritmo. Questa è la lezione 2 di 4.
Quanto tempo richiede la lezione «Serial.print e println»?
La maggior parte delle lezioni CoddyKit richiede circa 5–10 minuti. Ogni lezione è breve e interattiva, quindi fai progressi costanti e riprendi esattamente da dove hai lasciato su web e app.
Posso scrivere ed eseguire codice in questa lezione Arduino & IoT Academy?
Sì. Ogni lezione Arduino & IoT Academy include un editor di codice integrato, quindi scrivi ed esegui codice reale direttamente nel tuo browser e ricevi feedback istantaneo dall'IA — nessuna configurazione locale necessaria.
Tutte le lezioni di questo corso
- Serial.begin e baud rate
- Serial.print e println
- Osservare i valori dei sensori in tempo reale
- Leggere i comandi digitati