อ่านปุ่มหมุนโพเทนชิโอมิเตอร์
ต่อโพเทนชิโอมิเตอร์และดูค่าที่เปลี่ยนเมื่อหมุน
อ่านปุ่มหมุนโพเทนชิโอมิเตอร์ เป็นบทเรียน Arduino & IoT Academy ฟรีบน CoddyKit นี่คือบทเรียนที่ 3 จากทั้งหมด 4 บทเรียน คุณสามารถอ่านบทเรียนทั้งหมดด้านล่างฟรี — จากนั้นลองปฏิบัติด้วยตัวคุณเองในเบราว์เซอร์พร้อมตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7 บทเรียนนี้เป็นส่วนหนึ่งของเส้นทางการเรียน 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.
คำถามที่พบบ่อย
บทเรียน “อ่านปุ่มหมุนโพเทนชิโอมิเตอร์” ฟรีหรือไม่
ใช่ — ข้อความเต็มของ “อ่านปุ่มหมุนโพเทนชิโอมิเตอร์” ฟรีให้อ่านที่นี่บนเว็บ เพื่อปฏิบัติแบบโต้ตอบ (ตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7) และปลดล็อคส่วนที่เหลือของคอร์ส Arduino & IoT Academy ให้อัปเกรดเป็น CoddyKit PRO คอร์ส Arduino & IoT Academy มีบทเรียนทั้งหมด 4 บทเรียน
คุณจะเรียนรู้อะไรในบทเรียน “อ่านปุ่มหมุนโพเทนชิโอมิเตอร์”
ต่อโพเทนชิโอมิเตอร์และดูค่าที่เปลี่ยนเมื่อหมุน คุณปฏิบัติ Arduino & IoT Academy ด้วยโค้ดที่ใช้งานได้จริงที่คุณเรียกใช้โดยตรงในเบราว์เซอร์ และติวเตอร์ AI ตลอด 24/7 ตอบคำถามของคุณขณะที่คุณไปผ่านบทเรียน
คุณต้องมีประสบการณ์ก่อนที่จะเริ่มเรียน Arduino & IoT Academy หรือไม่
ไม่จำเป็นต้องมีประสบการณ์มาก่อน Arduino & IoT Academy บน CoddyKit ออกแบบมาสำหรับผู้เริ่มต้นไปจนถึงผู้เรียนขั้นสูง คุณสามารถเริ่มต้นที่นี่หรือเริ่มจากตัวแรกและเรียนด้วยความเร็วของคุณเอง นี่คือบทเรียนที่ 3 จากทั้งหมด 4 บทเรียน
บทเรียน “อ่านปุ่มหมุนโพเทนชิโอมิเตอร์” ใช้เวลานานแค่ไหน
บทเรียน CoddyKit ส่วนใหญ่ใช้เวลาประมาณ 5–10 นาที แต่ละบทเรียนจึงสั้นและเป็นแบบโต้ตอบ คุณสามารถก้าวหน้าอย่างต่อเนื่องและกลับมาเรียนต่อจากตรงที่เพิ่งหยุดบนเว็บและแอปได้เลย
ฉันเขียนและรันโค้ดในบทเรียน Arduino & IoT Academy นี้ได้ไหม
ได้ บทเรียน Arduino & IoT Academy ทุกบทมีตัวแก้ไขโค้ดในตัว คุณจึงเขียนและรันโค้ดจริงได้เลยในเบราว์เซอร์ และได้รับข้อเสนอแนะจาก AI ในทันที — ไม่ต้องติดตั้งในเครื่องของคุณ
บทเรียนทั้งหมดในหลักสูตรนี้
- สัญญาณดิจิทัลเทียบกับแอนะล็อก
- analogRead คืนค่า 0–1023
- อ่านปุ่มหมุนโพเทนชิโอมิเตอร์
- map() ค่าไปยังช่วงใหม่