0Pricing
Arduino & IoT Academy · レッスン

Arduinoのint、float、bool

センサーデータやフラグを保持する適切な型を選びます。

「Arduinoのint、float、bool」はCoddyKit上の無料Arduino & IoT Academyレッスンです。 これはレッスン1/4です。 下記で完全なレッスンを無料で読むことができます。その後、ブラウザ内の組み込みコードエディタと24時間対応のAIチューターでハンズオン演習できます。 これはArduino & IoT Academy学習パスの一部であり、ウェブとCoddyKitアプリ全体で進捗が同期されます。 Arduino & IoT Academyコースには全4レッスンが含まれています。

このレッスンの一部はまだ翻訳されておらず、英語で表示されています。

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. 🎯

よくある質問

「Arduinoのint、float、bool」レッスンは無料ですか?

はい。「Arduinoのint、float、bool」の完全なテキストはこのウェブで無料で読めます。インタラクティブに演習し(組み込みコードエディタと24時間対応のAIチューター)、Arduino & IoT Academyコースの残りをアンロックするには、CoddyKit PROにアップグレードしてください。 Arduino & IoT Academyコースには全4レッスンが含まれています。

「Arduinoのint、float、bool」で何を学びますか?

センサーデータやフラグを保持する適切な型を選びます。 ブラウザで直接実行するハンズオンコードでArduino & IoT Academyを演習し、24時間対応のAIチューターがレッスンを進める中での質問に答えます。

Arduino & IoT Academyを始めるのに経験は必要ですか?

事前経験は必要ありません。CoddyKitのArduino & IoT Academyは初級者から上級者向けに構成されているため、ここから始めるか最初から始めて、自分のペースで進むことができます。 これはレッスン1/4です。

「Arduinoのint、float、bool」レッスンにはどのくらい時間がかかりますか?

ほとんどのCoddyKitレッスンは約5~10分かかります。各レッスンはコンパクトでインタラクティブなので、着実に進歩し、ウェブとアプリ全体で正確に前回の場所から再開できます。

このArduino & IoT Academyレッスンでコードを書いて実行できますか?

はい。すべてのArduino & IoT Academyレッスンに組み込みコードエディタが含まれているため、ブラウザでリアルコードを書いて実行し、即座のAIフィードバックを取得できます。ローカル設定は不要です。

このコースのすべてのレッスン

  1. Arduinoのint、float、bool
  2. delay()ですべてが停止する理由
  3. millisでdelayなしに点滅させる
  4. 2つの処理を同時に実行する
← Arduino & IoT Academyに戻る