ต่อปุ่มบนเบรดบอร์ด
เชื่อมต่อปุ่มกดให้เรียบร้อยด้วยตัวดึงขึ้น
ต่อปุ่มบนเบรดบอร์ด เป็นบทเรียน Arduino & IoT Academy ฟรีบน CoddyKit นี่คือบทเรียนที่ 4 จากทั้งหมด 4 บทเรียน คุณสามารถอ่านบทเรียนทั้งหมดด้านล่างฟรี — จากนั้นลองปฏิบัติด้วยตัวคุณเองในเบราว์เซอร์พร้อมตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7 บทเรียนนี้เป็นส่วนหนึ่งของเส้นทางการเรียน Arduino & IoT Academy และความก้าวหน้าของคุณจะซิงค์ข้ามเว็บและแอป CoddyKit คอร์ส Arduino & IoT Academy มีบทเรียนทั้งหมด 4 บทเรียน
บางส่วนของบทเรียนนี้ยังไม่ได้รับการแปล และแสดงเป็นภาษาอังกฤษ
Time to Build It
You've written the code; now make it real. You'll wire a push button on a breadboard so the Arduino can actually feel your press.
Meet the Push Button
A tactile push button has four legs, but they're really just two pairs. Pressing it connects one pair to the other inside.
Mind the Center Gap
Straddle the button across the breadboard's center gap. That keeps the two sides separate until a press bridges them together.
Lean on the Internal Pull-Up
Thanks to INPUT_PULLUP, you skip the external resistor entirely. The board holds the pin HIGH for you, so wiring stays tiny.
One Leg to the Pin
Run a jumper from one button leg to a digital pin, say pin 2. This is the line the Arduino will read for presses.
Other Leg to Ground
Connect the opposite leg to GND. When you press, the pin gets pulled down to ground and your code sees LOW.
Use the Diagonal Legs
Because the legs are paired, wire to ones that sit diagonally across the button. That guarantees you bridge the two real contacts.
Power Off While Wiring
Unplug the USB before moving wires. Building with the board powered off avoids shorts and protects the Arduino from mistakes. 🔋
Match Code to Wiring
Your sketch must name the same pin you wired. Set pin 2 to INPUT_PULLUP so the software and the hardware agree.
void setup() {
pinMode(2, INPUT_PULLUP);
}Test with Serial
Upload, open the Serial Monitor, and press. Seeing the value drop to 0 confirms your button and wiring both work.
Troubleshoot Calmly
No change on press? Check the diagonal legs, confirm the GND wire, and make sure the code uses the exact pin you plugged into.
Quick Check
Think about where the button's two legs should connect.
Recap
You wired a button across the center gap, one leg to pin 2 and one to GND, then confirmed it on Serial. You can now sense the real world! 🎉
คำถามที่พบบ่อย
บทเรียน “ต่อปุ่มบนเบรดบอร์ด” ฟรีหรือไม่
ใช่ — ข้อความเต็มของ “ต่อปุ่มบนเบรดบอร์ด” ฟรีให้อ่านที่นี่บนเว็บ เพื่อปฏิบัติแบบโต้ตอบ (ตัวแก้ไขโค้ดในตัวและติวเตอร์ 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 ออกแบบมาสำหรับผู้เริ่มต้นไปจนถึงผู้เรียนขั้นสูง คุณสามารถเริ่มต้นที่นี่หรือเริ่มจากตัวแรกและเรียนด้วยความเร็วของคุณเอง นี่คือบทเรียนที่ 4 จากทั้งหมด 4 บทเรียน
บทเรียน “ต่อปุ่มบนเบรดบอร์ด” ใช้เวลานานแค่ไหน
บทเรียน CoddyKit ส่วนใหญ่ใช้เวลาประมาณ 5–10 นาที แต่ละบทเรียนจึงสั้นและเป็นแบบโต้ตอบ คุณสามารถก้าวหน้าอย่างต่อเนื่องและกลับมาเรียนต่อจากตรงที่เพิ่งหยุดบนเว็บและแอปได้เลย
ฉันเขียนและรันโค้ดในบทเรียน Arduino & IoT Academy นี้ได้ไหม
ได้ บทเรียน Arduino & IoT Academy ทุกบทมีตัวแก้ไขโค้ดในตัว คุณจึงเขียนและรันโค้ดจริงได้เลยในเบราว์เซอร์ และได้รับข้อเสนอแนะจาก AI ในทันที — ไม่ต้องติดตั้งในเครื่องของคุณ
บทเรียนทั้งหมดในหลักสูตรนี้
- INPUT เทียบกับ INPUT_PULLUP
- อ่านสถานะปุ่ม
- if/else: LED ทำตามปุ่ม
- ต่อปุ่มบนเบรดบอร์ด