0Pricing
Arduino & IoT Academy · 课时

在面包板上连接按钮

使用上拉电阻整洁地连接按钮

在面包板上连接按钮 是 CoddyKit 上的免费 Arduino & IoT Academy 课时。 这是第 4 节课,共 4 节。 你可以在下方免费阅读本课时的完整内容 — 然后在浏览器中使用内置代码编辑器和全天候 AI 导师进行实践。 这是 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 导师)并解锁 Arduino & IoT Academy 课程的其余内容,请升级到 CoddyKit PRO。 Arduino & IoT Academy 课程共包含 4 节课。

「在面包板上连接按钮」这节课中我会学到什么?

使用上拉电阻整洁地连接按钮 你通过在浏览器中直接运行的动手代码来练习 Arduino & IoT Academy,全天候 AI 导师会在你学习这节课的过程中回答你的问题。

学习 Arduino & IoT Academy 需要有经验吗?

无需任何先前经验。CoddyKit 上的 Arduino & IoT Academy 课程适合初学者到高级学习者,你可以从这里开始或从头开始,按照自己的节奏学习。 这是第 4 节课,共 4 节。

「在面包板上连接按钮」课时需要多长时间?

大多数 CoddyKit 课程大约需要 5–10 分钟。每节课都很精短且互动,所以你能稳步进步,并在网页和应用中从离开的地方继续。

我能在这节 Arduino & IoT Academy 课中编写并运行代码吗?

能。每节 Arduino & IoT Academy 课都包含内置代码编辑器,你可以在浏览器中直接编写并运行真实代码,并获得即时 AI 反馈 — 无需本地设置。

此课程中的所有课时

  1. INPUT 与 INPUT_PULLUP
  2. 读取按钮状态
  3. if/else:LED 跟随按钮
  4. 在面包板上连接按钮
← 返回 Arduino & IoT Academy