0Pricing
Arduino & IoT Academy · レッスン

明るさのしきい値を設定する

読み取り値に応じて動作する「十分暗い」の基準を決めます。

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

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

Raw Numbers Need Meaning

An analog reading like 312 means nothing on its own. A threshold turns that number into a clear decision: dark or bright.

What a Threshold Is

A threshold is a cutoff value. Readings on one side count as dark, and readings on the other count as bright.

Store It in a Variable

Keep your cutoff in a named variable so it is easy to find and adjust later in one place.

int threshold = 400;

Compare With if

Use an if statement to compare the live reading against your threshold and branch your logic from there.

if (light < threshold) {
  // it is dark
}

Direction Depends on Wiring

Whether dark means a higher or lower number depends on how you wired the divider. Confirm it before you trust the test.

Find Your Number

Print readings in a bright room and a dark one, then pick a midpoint between them as your starting threshold.

Add else for Bright

Pair your if with an else so the bright case is handled too, instead of doing nothing when light is high.

else {
  // it is bright
}

One Cutoff Causes Flicker

Near the line, tiny changes can flip the result back and forth. This rapid flicker looks like a glitch.

Add Hysteresis

Hysteresis uses two cutoffs: one to switch on and a different one to switch off. The gap stops nervous flicker.

Make It Adjustable

Feed the threshold from a potentiometer so anyone can dial in dark without re-uploading code.

Thresholds Drive Decisions

This same threshold idea works for temperature, moisture, and distance. It is how sensors become decisions.

Quick Check

What problem does hysteresis solve at a light threshold?

Recap: Deciding on Light

You stored a threshold, compared readings with if and else, and added hysteresis so the decision stays steady.

よくある質問

「明るさのしきい値を設定する」レッスンは無料ですか?

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

「明るさのしきい値を設定する」で何を学びますか?

読み取り値に応じて動作する「十分暗い」の基準を決めます。 ブラウザで直接実行するハンズオンコードでArduino & IoT Academyを演習し、24時間対応のAIチューターがレッスンを進める中での質問に答えます。

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

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

「明るさのしきい値を設定する」レッスンにはどのくらい時間がかかりますか?

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

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

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

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

  1. PIR人感センサーを読み取る
  2. LDRで明るさを測る
  3. 明るさのしきい値を設定する
  4. 自動ナイトライト
← Arduino & IoT Academyに戻る