ポテンショメーターのつまみを読み取る
ポテンショメーターを配線し、回したときの値の変化を確認します
「ポテンショメーターのつまみを読み取る」はCoddyKit上の無料Arduino & IoT Academyレッスンです。 これはレッスン3/4です。 下記で完全なレッスンを無料で読むことができます。その後、ブラウザ内の組み込みコードエディタと24時間対応のAIチューターでハンズオン演習できます。 これはArduino & IoT Academy学習パスの一部であり、ウェブとCoddyKitアプリ全体で進捗が同期されます。 Arduino & IoT Academyコースには全4レッスンが含まれています。
このレッスンの一部はまだ翻訳されておらず、英語で表示されています。
Meet the Potentiometer
A potentiometer, or pot, is a knob you turn to change resistance. It is the easiest analog input to start experimenting with.
It Has Three Pins
A pot has three legs: two outer pins for power and ground, and a middle wiper pin that gives the changing voltage.
Wire the Outer Pins
Connect one outer pin to 5V and the other to GND. This sets up the full voltage range across the pot.
Wire the Wiper to A0
Run the middle wiper pin to an analog input like A0. As you turn the knob, the voltage on that pin moves.
It Is a Voltage Divider
Inside, the pot acts as a voltage divider. Turning the shaft moves a contact that splits 5V into the reading you sense.
Read the Knob in Code
Reading it is one line. Call analogRead(A0) and you get a value from 0 to 1023 that tracks the knob position.
int pot = analogRead(A0);Fully Left Reads 0
Turn the knob all the way toward the GND side and the reading drops to about 0. The wiper now sees zero volts.
Fully Right Reads 1023
Turn it fully toward the 5V side and the value climbs to about 1023. The wiper now sees the full supply voltage.
Print It to Watch
Send the value to the Serial Monitor so you can watch it change live. Use Serial.println inside your loop.
Serial.println(analogRead(A0));Add a Small Delay
A brief delay keeps the Serial Monitor readable instead of a blur. Ten milliseconds is plenty between samples.
delay(10);A Hands-On Analog Lab
The pot is your personal analog lab. Twisting it is the quickest way to feel how voltage becomes a number.
Quick Check
Which pot pin feeds the Arduino its reading?
Recap: Reading a Knob
You wired a potentiometer with outer pins on 5V and GND and the wiper on A0. Now analogRead tracks the knob from 0 to 1023.
よくある質問
「ポテンショメーターのつまみを読み取る」レッスンは無料ですか?
はい。「ポテンショメーターのつまみを読み取る」の完全なテキストはこのウェブで無料で読めます。インタラクティブに演習し(組み込みコードエディタと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フィードバックを取得できます。ローカル設定は不要です。
このコースのすべてのレッスン
- デジタル信号とアナログ信号
- analogRead は 0~1023 を返す
- ポテンショメーターのつまみを読み取る
- map() で値を新しい範囲に変換する