Arduino Mega 2560 Failture?????

Hi, I'm using google translator apology but only speak Spanish.

I have a problem with the Arduino Mega 2560 (AT2560 16AU)

the problem is when I connect the Arduino Mega to a port (which always and connected and works corretamente, look at the silver single LED lights Power and L but the TX and RX not flashing as they always do and to compile a code out this error message ..

El Sketch usa 6.834 bytes (2%) del espacio de almacenamiento de programa. El máximo es 253.952 bytes.
Las variables Globales usan 819 bytes (9%) de la memoria dinámica, dejando 7.373 bytes para las variables locales. El máximo es 8.192 bytes.
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_getsync(): timeout communicating with programmer
Ha ocurrido un error mientras se enviaba el sketch

help Me please

Do you have three exclaimation points in a row in a string in the program? There's a bug in old versions of the bootloader that chokes if it sees three exclamation points in a row. The bug was long since fixed, but lots of clones ship with bootloaders effected by that bug. (ex, Serial.println("Hello World!!!"); would trigger the bug. Serial.println("Hello World!!"); would not)

(note - it could be many things that are causing it, not just this. The signature of this is the upload proceeding part of the way and then choking in the middle - but you can't tell if that's what happened from looking at the error after the fact)

#include <SPI.h>
#include <SD.h>
#include <Ultrasonic.h>



  int ir = 12;
  int dir = 0;
  int Pin_echo = 9;
  int Pin_trig = 8;
  int v = 0;
void setup() {
  Serial.begin (9600);
    pinMode(Pin_trig, OUTPUT);
    pinMode(Pin_echo, INPUT);
    pinMode(ir, INPUT);
    pinMode(11, OUTPUT);
    pinMode(7, OUTPUT);
    pinMode(49, OUTPUT);     //pines del display
    pinMode(48, OUTPUT);
    pinMode(47, OUTPUT);
    pinMode(46, OUTPUT);
    pinMode(45, OUTPUT);
    pinMode(43, OUTPUT);
    pinMode(42, OUTPUT);
    pinMode(40, OUTPUT);
   }

void loop() {
 
  int duracion, cm;
    digitalWrite(Pin_trig, LOW);
    delayMicroseconds(2);
    digitalWrite(Pin_trig, HIGH);
    delayMicroseconds(10);
    digitalWrite(Pin_trig, LOW);
    duracion = pulseIn(Pin_echo, HIGH);
    cm = duracion / 29 / 2;
    Serial.print("Distancia:");
    Serial.print(cm);
    Serial.println(" cm");
    delay (200);
     
     dir= digitalRead(ir);
 if(digitalRead(dir)==LOW)
   {
     digitalWrite(11, HIGH);
   }
 else
   {
     digitalWrite(11,LOW);
   }
  Serial.println("IRobt 1="); Serial.println(dir);
  digitalWrite(7, HIGH);
  delay(500);
  digitalWrite(7, LOW);
  delay(500);
  digitalWrite(49, HIGH);
  digitalWrite(48, HIGH);
  digitalWrite(47, HIGH);
  digitalWrite(46, HIGH);
  digitalWrite(45, HIGH);
  digitalWrite(44, HIGH);
  digitalWrite(43, HIGH);
  digitalWrite(42, HIGH);
  digitalWrite(40, HIGH);
  
}

In my code does not ("!!!")

not this going on, the computer correctly recognizes everything is correct drivers, board, USB cable

Someone else has an idea how to fix it? I do not have money to buy another Arduino Mega :frowning:

Have you performed the loop back test?
-> This tests USB to Serial communication

If works, then,
Are you able to upload the "Blink" sketch?
-> If so, then it could be something code related.

If Blink upload fails, but loop back passes, then it is likely your bootloader is corrupted.