# arduino IDE isn't able to load skethes to my arduino mega board

I made a big mistake: I've written a small sketch just to play with my new arduino mega 2560. The sketch worked fine but a bit slow, so I thought that if I increase the baud-rate I will get faster communication to my computer. So I changed the baud-rate to 14400 (in the Serial.begin(); statement).

Now I'm not able to upload sketches any more, and I don't know how to solve this, I tried to burn the bootloader again but I don't know how to do it.

The sketch:

const int pin_in=A0;
const int cols=151;
int value;
int prev;

void setup() {
Serial.begin(9600);
//  Serial.begin(14400);
}

void loop() {
value=map(value,0,1023,0,cols);
for (int i=0; i<cols; i++){
if (i==value){
if (value==prev){Serial.print("|");}
else if(value<prev){Serial.print("/");}
else if(value>prev){Serial.print("\\");}
} else if (i%30==0){Serial.print("|");}
else {Serial.print(" ");}
}
Serial.println("|");
prev=value;
delay(1);
}


When I try to upload my sketch (or any example sketch) I get error while opening /dev/ttyACMX although its present before trying to upload the sketch.

processing.app.SerialException: Error al obrir el port sèrie "/dev/ttyACM0".
at processing.app.Serial.<init>(Serial.java:178)
at processing.app.Serial.<init>(Serial.java:77)
at processing.app.Sketch.exportApplet(Sketch.java:1627)
at processing.app.Sketch.exportApplet(Sketch.java:1599)
at processing.app.Editor$DefaultExportHandler.run(Editor.java:2380) at java.lang.Thread.run(Thread.java:744) Caused by: gnu.io.UnsupportedCommOperationException: Invalid Parameter at gnu.io.RXTXPort.setSerialPortParams(RXTXPort.java:213) at processing.app.Serial.<init>(Serial.java:163) ... 9 more processing.app.debug.RunnerException: Error al obrir el port sèrie "/dev/ttyACM0". at processing.app.debug.Uploader.flushSerialBuffer(Uploader.java:101) at processing.app.debug.AvrdudeUploader.uploadViaBootloader(AvrdudeUploader.java:175) at processing.app.debug.AvrdudeUploader.uploadUsingPreferences(AvrdudeUploader.java:67) at processing.app.Sketch.upload(Sketch.java:1671) at processing.app.Sketch.exportApplet(Sketch.java:1627) at processing.app.Sketch.exportApplet(Sketch.java:1599) at processing.app.Editor$DefaultExportHandler.run(Editor.java:2380)


Is there a way to reset an arduino mega 2560 board?

• If my very poor Spanish skills are serving me correctly, the error message you're receiving is saying that Arduino IDE could not properly open the serial port that the Mega is connected to. If you've tried power-cycling, checking the serial port on your computer (using lsusb, or equivalent), restarting, etc... try programming the Mega using the ICSP header (you can do this with an AVR programmer, or another Arduino using the ArduinoISP sketch). You might try flashing the bootloader (Tools > Burn Bootloader in the IDE). – Jason Wright Feb 18 '14 at 1:56
• The bootloader shouldn't change when uploading a sketch. Try disconnecting and reconnecting the Arduino and check if the board is recognized using dmesg. Does ls -l /dev/ttyA* actually show anything when the Arduino is connected? BTW: My Megas register as /dev/ttyUSBn. – jippie Feb 18 '14 at 6:16
• restart your system first, afterwards look if the 2560 board registered right! – kimliv Feb 18 '14 at 11:26
• check if your COM PORT is accessible! – dmSherazi Feb 18 '14 at 11:49
• I've already tried all of these options, the board is visible as /dev/ttyACMx (also with lsusb) before trying to upload a sketch, I didn't try to burn the bootloader because I don’t have any ICSP programer, (I'm waiting for it to arrive) (actually it isn't Spanish it's Catalan very similar) – Falk Feb 18 '14 at 16:03

I'm Really sorry I wasted your time, I finally discovered it was a software bug, not hardware. trying the board on a different computer worked fine. trying a different board on my laptop made the same bug. When I uninstalled the IDE and re-installed it after that the problem remained. Finally I solved it deleting the preferences file, the hardware folder and the libraries folder (those which are on the sketchbook folder). Thank you anyway.

I had this same issue. My Arduino IDE worked fine for months on Ubuntu. Then one day I flashed a program and changed the baud rate for serial to something other than 9600. From that point on I could no longer upload to the Arduino. I could still do it from the Mac and Windows Arduino IDE, but not linux. For so long I read through stuff like adding yourself to the dialout group, reinstall java, etc. Turns out deleting just the preferences file worked. What I did was open Arduino IDE (Arduino not plugged in) go to->File->preferences then down at the bottom of that window you can click on the file path directly for the preferences.txt. Do that, delete the preferences.txt file. Restart the IDE, A dialog box pops up asks where to put new preferences file, choose the /sketchbook. Then plug in the Arduino it should say Arduino on COM1 in the IDE footer. Go to the blink sketch in examples and upload. when it asks what serial port say ACM0 (these might be different for your setup). it should work, did for me. I did not have to delete the libraries or hardware folder. Only preferences. Good luck!

I fell the same situation in Debian. I changed the baudrate in the sketch and the monitor. It was a hard moment.

I deleted the preferences.txt file in my home directory as mentioned above and voilà the connection with my ArduionoUNO works again without any serious work.