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.
A:
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.
D4V360
2010-01-23 11:50:00
The initial state of the led is off. For some reason it seem that Arduino does reset itself when I use the dev environment or my java test app but not when I use C#.
Petezah
2010-01-23 11:58:04
Figures; maybe the Java and Serial monitor close the serial connection and the C# app doesn't? Fact is that your arduino needs to reset before being able to send/receive serial data.
D4V360
2010-01-24 12:38:29
Put a simple bit of code in the setup() part of your program on the Arduino - make it flash the LED twice (and leave it in the off state afterwards). That way you can know it has been reset and that you main program is ready for input...
Alan Moore
2010-01-25 13:56:33