Arduino串行监视器和java重置变量
我编写了一个小应用程序来打开连接到我的 Arduino 板的 LED 灯。应用程序通过 USB 端口发送特定字节值以打开 LED 和特定值以将其关闭。奇怪的是,由于某种原因,当我在arduino开发环境中使用串行监视器打开LED,然后关闭串行监视器时,如果我没有输入正确的字节值,LED就会关闭,在我的java测试中也会发生同样的情况应用程序。让我困惑的是,在我的 C# 应用程序中,我可以发送正确的字节值来打开 LED,然后关闭我的应用程序,并且 LED 仍然亮着。我完全困惑为什么会发生这种情况。
I wrote a small app to turn on an LED light connected to my Arduino board. The app sends in a certain byte value to turn on the LED and a certain value to turn it off through the USB port. The strange thing is that for some reason when I use the serial monitor in the arduino development environment to turn on the LED and then close the serial monitor the LED turns off without me inputting the right byte value, the same also happens in my java test app. What puzzles me is that in my C# app I can send in the right byte value to turn on the LED then turn off my app and the LED is still on. I'm totally confused why this is happening.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
从Arduino Uno http://arduino.cc/en/Main/ArduinoBoardUno的描述来看:
如果您在 Windows 下使用 C#,则该板不会在 USB 连接上重置。我假设您在其他平台上运行 Java。
From the description of the Arduino Uno http://arduino.cc/en/Main/ArduinoBoardUno:
If you are using C# under Windows, the board does not reset on USB connect. I assume you run the Java on some other platform.
LED 的初始状态是什么,亮还是灭?
当您通过串行监视器等方式打开与 Arduino 的串行连接时,Arduino 会自行重置。
What is the initial state of the led, on or off?
Arduino's reset themselves when you open a serial connection to them through for example the serial monitor.
我刚刚在另一个线程中遇到了答案(对于 C#):
如何使用 C# 应用程序重置 Arduino Mega2560?
在 C# 中设置串行端口对象 DtrEnable=true,现在当我使用 C# 连接时,Arduino 会重置。
I just ran across the answer (for C#) in another thread here:
How do I reset my Arduino Mega2560 with my C# application?
Set the serial port object DtrEnable=true in C# and now the Arduino resets when I connect with C#.