Petezah
Petezah

Reputation: 1525

Arduino serial monitor and java resets variables

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.

Upvotes: 1

Views: 1097

Answers (3)

Matt
Matt

Reputation: 447

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#.

Upvotes: 0

Anthon
Anthon

Reputation: 76742

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.

Upvotes: 1

fijter
fijter

Reputation: 18057

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.

Upvotes: 0

Related Questions