Really erasing Arduino Mega Board

Hello,

I have been playing with uploading different sketches to my Arduino Mega board. One of them controls Six servos on pins (2,3,4,5,6 and 7). See my post here (http://forum.arduino.cc/index.php?topic=384432.0).

Now my question: I am uploading additional test project sketches (Blink) and I can see that the Arduino is still running some of the old servo sketchs.

I searched many source to how to re-set Arduino board to empty any sketch but they do not seem to work! Some example: upload empty sketch, press re-set button while connect/disconnect USB cable, etc.

How can I really erase Arduino Mega board especially removing the signal stored in the pins that keeps running my servos!!!

Thanks for the help...

I am uploading additional test project sketches (Blink) and I can see that the Arduino is still running some of the old servo sketchs.

The Arduino can only run one program at a time. What makes you think that it is running some of the servo programs ?

Is it running the Blink program ?

Any chance that you're using the same pin in the blink sketch that used to control the servo?

Hi UKHeliBob - When I upload the Blink sketch, I do not see it blinking and also I can see the servos running

Hi sterretje - no, I am using pin 13 for the blink sketch. The servos are connected to pins (2,3,4,5,6 and 7).

Thanks.

When I upload the Blink sketch, I do not see it blinking

It sounds like it is not uploading. If so, no wonder the servo program has not been replaced.

What messages do you get when you upload the Blink program ?

Do the servos have a ground connection to the Arduino?

Hi AWOL - I have disconnected the 5V and GND from the servos. So the servos do not have Ground connection to the Arduino.

The error message is:

Arduino: 1.6.7 (Windows 7), Board: "Arduino/Genuino Mega or Mega 2560, ATmega2560 (Mega 2560)"

Sketch uses 1,518 bytes (0%) of program storage space. Maximum is 253,952 bytes. Global variables use 9 bytes (0%) of dynamic memory, leaving 8,183 bytes for local variables. Maximum is 8,192 bytes. avrdude: ser_open(): can't open device "\.\COM13": The system cannot find the file specified.

avrdude: ser_drain(): read error: The handle is invalid.

Problem uploading to board. See http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions.

So all is clear. Due to an error it did not get as far as ever loading your new Blink sketch. The old Servo sketch is still loaded.

So the Blink program is not being uploaded to the Arduino. No wonder the servo program keeps running.

Check the COM port being used by the Arduino.

... so I managed to get the Blink program uploaded in Arduino board, and it is blinking! I also have disconnected the wires connected to the servo pins.

but the servos are still running.?!?!?

Are the servos just moving randomly or are they moving as per the original program (unlikely) Are they real servos or continuous rotation "servos" ?

I also have disconnected the wires connected to the servo pins.

Clearly these are patentable devices - servos which run without power.

I am using continuous rotation servos [https://www.sparkfun.com/products/9347]. But I am also sing the stop code: myservo7.write(90);

... what's the meaning of patentable devices":-) :-)

I found this discussion about burning the Arduino bootloader (http://forum.arduino.cc/index.php?topic=72323.0), to clear sketches on Arduino board.

Has anyone tried it before? How do I do that.

Thank you for the help.

But I am also sing the stop code: myservo7.write(90);

But as you have disconnected the signal wires from the Arduino you are not actually writing to the "servo" and it is picking up random signals.

what's the meaning of patentable devices"

I think that AWOL meant that if you have removed all of the servo connections, including power, then they are still moving with no power applied which would be an idea worth patenting if it were true.

picking up random signals

yes, that is what is happening probably. It is picking random signals or left overs from previous servo runs which I have been testing with. I have a feeling that it has to do with serial flood!!

then they are still moving with no power applied

No. the servos do turn if the power is off ... :) :)

or left overs from previous servo runs which I have been testing with

In reply #6 you said that you had disconnected the 5V and GND connections so how is power getting to the “servos” ?

Hi UKHeliBob

I am sorry if I got you confused, but just to confirm that: 1) When I disconnect the GND and 5V from the board, the servos do not turn. 2) But when I connect them again the servos keeps rotating in random, as if they are receiving left over of previous signals.

I am thinking may be if I create a new sketch with instructions to flush the serial data then it may re-fresh the program. Does anyone has link to such example code?

Thanks

If you reset an Arduino, there will not be data in the serial buffer. You're barking up the wrong horse (read: have the wrong idea about the problem)

I don't know how servos work (never used them) but if there are control wires, they might pick up signals if they are not connected or if you don't define the pins that they are connected to as outputs (and probably set them low). Connect the wires to GND or to Vcc (depending on what makes them turn).

zakim: ... 1) When I disconnect the GND and 5V from the board, the servos do not turn. 2) But when I connect them again the servos keeps rotating in random, as if they are receiving left over of previous signals. ...

  1. Bob was confused because your previous post left out the word "not" and you wrote: "the servos do turn if the power is off"

2: You are connecting them to pins that are not used in your "blink" sketch. When Arduino pins are not specified as HIGH or LOW, then they "float". Floating pins have a random, changing value. This changing value is fed to your powered up servo, and causes it to turn at random.

Fix this by writing LOW (or HIGH if you prefer) to unused pins in your setup() routine.

NOTE: This is NOT a case of previously loaded code running when it is not expressly loaded. Arduinos do not have a multi-tasking operating system (like Windows, MacOSX, or Unix (Linux)), so they cannot run a second program "in the (non-existant) background".