Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
为什么当我使用 Arduino Uno 时“NUM_DIGITAL_PINS”返回 20?
如何获得 arduino 中的数字引脚数?
我正在使用 Arduino 1.0.5 IDE
谢谢
按照惯例,NUM_DIGITAL_PINS(全部大写)是一个宏。它的值是在编译时确定的。它实际上是通过文字替换来完成的。它不会“返回”任何东西。函数会返回不同的值,但它们看起来更像GetNumDigitalPins().
NUM_DIGITAL_PINS
GetNumDigitalPins()
如果你想知道为什么当 Uno 的数字引脚从 0 到 13 时数字是 20,是因为六个模拟引脚实际上也可以充当数字引脚。所以总的数字引脚是 20。