# Arduino UNO按键消抖运行一段时间后卡死

> 原文链接：https://robotics.hellobike.com/pitfalls/2013-12-26-robotics-se-2083
> 频道：pitfalls | 更新日期：2013-12-26 | 标签：auto, stackexchange, arduino, c, serial, communication
> 核心摘要：Arduino UNO运行按键消抖与LED切换代码会卡死，改用USB供电后恢复正常。

# Arduino UNO按键消抖运行一段时间后卡死

::: v-pre
> 本文由 AI 根据公开内容整理，可能有误，请以原文为准：[Arduino Uno getting a type of "HANGED" while runing samll code of switc debounce and Serial print](https://robotics.stackexchange.com/questions/2083/arduino-uno-getting-a-type-of-hanged-while-runing-samll-code-of-switc-debounce)（Robotics Stack Exchange #2083）

**状态**：已解决

## 问题

Arduino UNO读取按键并做消抖，运行一段时间后板子类似`HANGED`，按键不再触发LED翻转，只能手动复位。

## 环境

Arduino UNO；按键接`buttonPin=2`，LED接`ledPin=13`；曾用`9v 1 Amp`适配器供电，后改USB供电。

## 解决办法

1. 停止使用`9v 1 Amp`适配器给Arduino UNO供电。
2. 改用USB线给板子供电。
3. 提问者表示USB供电后代码工作正常，推断此前是适配器供电导致发热并卡死。

原问题作者：shailendra；采纳答案作者：shailendra。原内容依 CC BY-SA 4.0 授权，本页摘要同样依 CC BY-SA 4.0 授权。
:::

## 原始参考来源 (Sources)

- [Robotics Stack Exchange #2083：Arduino Uno getting a type of "HANGED" while runing samll code of switc debounce and Serial print](https://robotics.stackexchange.com/questions/2083/arduino-uno-getting-a-type-of-hanged-while-runing-samll-code-of-switc-debounce)