Arduino串行监视器和java重置变量

发布于 2024-08-18 21:27:30 字数 257 浏览 6 评论 0原文

我编写了一个小应用程序来打开连接到我的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

梦纸 2024-08-25 21:27:30

从Arduino Uno http://arduino.cc/en/Main/ArduinoBoardUno的描述来看:

This setup has other implications. When the Uno is connected to either 
a computer running Mac OS X or Linux, it resets each time a connection 
is made to it from software (via USB).

如果您在 Windows 下使用 C#,则该板不会在 USB 连接上重置。我假设您在其他平台上运行 Java。

From the description of the Arduino Uno http://arduino.cc/en/Main/ArduinoBoardUno:

This setup has other implications. When the Uno is connected to either 
a computer running Mac OS X or Linux, it resets each time a connection 
is made to it from software (via USB).

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.

栀梦 2024-08-25 21:27:30

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.

番薯 2024-08-25 21:27:30

我刚刚在另一个线程中遇到了答案(对于 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#.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文