arduino - Arduino 如何检测 LED 的状态?

标签 arduino led

我正在为 Arduino 开发闪烁/褪色灯程序。我正在尝试构建一些基于 LED 状态和某些开关组合的交互性。考虑一下:按下按钮时,如果 LED 亮起,我想将其关闭;如果 LED 熄灭,我想将其打开。

但是,我无法找到有关确定 LED 状态的任何信息。最接近的是 this question关于 Android,但我想知道我是否可以从 Arduino 平台上做到这一点。有没有人有任何实践经验或建议?

最佳答案

读取输出端口是绝对可以的。那就是

digitalWrite(LED_PORT, !digitalRead(LED_PORT));

将切换引脚。

您可能还想考虑切换库:http://playground.arduino.cc/Code/DigitalToggle

关于arduino - Arduino 如何检测 LED 的状态?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14138176/

相关文章:

Android:屏幕关闭后保持摄像头 LED 亮起

Arduino无法同时在LED屏和串口监视器上输出

node.js - 字符串压缩可更快地刷新 WS2811 RGB LED

c++ - 阿杜诺 | RGB LED 灯条 Controller

python - 在两个 Arduino Mega 上用 pyfirmata 读取模拟值的问题

python - 阿杜诺和 python

serial-port - 我怎样才能 "reset"Arduino 板?

c# - 串口+C#数据接收问题

c++ - 如何让 LED 代码从键盘按键运行

c - 如何修复无法从 esp8266 响应读取serial.find ("OK")