int, float, bool su Arduino
Scelga il tipo corretto per contenere i dati dei sensori e i flag.
int, float, bool su Arduino è una lezione Arduino & IoT Academy gratuita su CoddyKit. Questa è la lezione 1 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.
Boxes for Your Data
A variable is a named box that holds a value while your sketch runs, so you can store a sensor reading once and reuse it later. 📦
Why Types Matter
On Arduino you must say what kind of value a box holds. The type decides how much memory it takes and what values fit inside it.
Whole Numbers with int
An int stores whole numbers like counts, pin numbers, or a 0 to 1023 sensor value. It is the type you will reach for most often.
int sensorValue = 512;int Has Limits
On an Uno an int holds roughly -32,768 to 32,767. Go past that and the number wraps around, which can cause sneaky bugs.
Decimals with float
A float holds numbers with a decimal point, like 23.5 degrees from a temperature sensor. Use it when whole numbers are too coarse.
float temperature = 23.5;float Is Approximate
A float trades exactness for range, so values are stored approximately. Avoid it for money or precise counting; it is great for sensors.
True or False with bool
A bool holds just true or false, perfect for a yes or no fact like whether a button is currently pressed or an LED is on.
bool ledOn = false;Name It Clearly
Give each variable name a clear meaning like buttonPin or doorOpen. Future you reads code faster when names say what they hold.
Declare Then Use
First you declare a variable with its type and a name, then you can read it or change it anywhere below in the same sketch.
int count = 0;
count = count + 1;Global vs Local
Declare a variable above setup to make it global and shared everywhere. Declare it inside a function and only that function can see it.
Pick the Right Type
Match the type to the data: int for counts and pins, float for temperatures, bool for flags. The right choice saves memory and prevents bugs.
Quick Check
Which type best stores a temperature reading of 23.5 degrees?
Recap
You now pick types like a pro: int for whole numbers, float for decimals, and bool for true or false flags. Clear names keep it all readable. 🎯
Domande Frequenti
La lezione «int, float, bool su Arduino» è gratuita?
Sì — il testo completo di «int, float, bool su Arduino» è 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 «int, float, bool su Arduino»?
Scelga il tipo corretto per contenere i dati dei sensori e i flag. 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 1 di 4.
Quanto tempo richiede la lezione «int, float, bool su Arduino»?
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
- int, float, bool su Arduino
- Perché delay() blocca tutto
- Far lampeggiare un LED senza delay usando millis
- Eseguire due attività contemporaneamente