Stops working the following day

Has anybody had a problem with the Arduino losing it’s program?
Problem: Host program sending “commands” to the Arduino(Serial port) and it works great.
The next day after powering up the Arduino does not respond to the host program. I upload the same I/O program and it runs great again.

Also:

And did it stop the following day?

Maybe you had some sort of glitch as you disconnected it which wrote a bad byte.

The code is below. I use C# to send a hex value to it. I just programmed this one hour ago with the code below but after plugging it back in a few minutes ago it stops responding to C#. ???? Do i need to store it to eeprom? I thought the arduino ide stores it into the flash (using the upload to i/o board) which should retain it after power is removed. Does anybody else have this problem?

int HexValueIn1 = 0;

void setup() { Serial.begin(19200); }

void loop() {

if (Serial.available() > 0) { HexValueIn1= Serial.read(); Serial.print(HexValueIn1, HEX);

}

}

I thought the arduino ide stores it into the flash

Yes it does, it should be retained through power cycles. You should be able to program it up and remove the computer and power it up separately and it should still work.

It is retaining the boot program otherwise you would not be able to upload to it. Are you sure you are doing nothing else to it? Are you leaving it connected as you power down the computer? Try just pulling the USB plug to disconnect it.

I actually remove the USB cable before powering down the computer.

Here is the simple code in the Arduino. int HexValueIn1 = 0; void setup() { Serial.begin(19200); }

void loop() {

if (Serial.available() > 0) { HexValueIn1= Serial.read(); Serial.print(HexValueIn1, HEX); } }

After uploading this to the Arduino i use my host program (C#) to send a byte for a response from the arduino. This works great until i power down the arduino and then plug it back in. C# at this point dosen't recieve anything from the arduino unless i upload the arduino code again. So i'm assuming the program was lost in the arduino. Why else would it not respond? It would be nice if there was a ardunio debugger that you could step through like you can with Visual basic.

To make sure it really is the Arduino losing the program and not a communication problem, try uploading the Blink example sketch. Pull the USB and power down. Plug it back in. Does the blink program start back up?

I upld'd the blink program and it works after i power cycle. I'm not sure why the serial port dosen't respond...Until i upload the program again. I think i'll have the Arduino send out chars on initital start up and see what happens.