Laptop not detecting my Arduino Mega(cloned) via USB port

Then, is the sketch inside still usable because when I plug it to my laptop there's still 2 LED lit, L and ON, so it means there's still power going in.

The ON-LED is directly connected to the 5V of the USB.

The L-LED is directly or indirectly connected to the 2560 (not behind a PC at the moment to check) and it depends on what your currently loaded sketch does with it what its state will be.

This is the code that I uploaded onto the Arduino before the incident:

// *** ON Going *** Test_H-Bridge_Electrom_V01_V01 August 2024
//	***
// Is just for test the Electromagnet with the H-Bridge, so can swap polarity and PWM the force of the Electromagnet
//	***
//
// Here we Test: the PWM of the Coil, the gap between the Board and the Coil, the Magnet used on the Pieces, the Weight of the piece
//
// The variables to change are:
// PWM (Only one on the code)
// Gap (Mechanical part of the board)
// Magnet Size and force (Mechanical Part of the Board)
// Weight of the Piece (Mehanical Part of the Board)
//
// The idea of this code is:
// With Power Off, put the pieces on the board.
// 
// Power On
// No Motor Coded here, so you have to move by hand the Trolley with the Electromagnet. 
// Touch D16 button for turn on the Electromagnet
// Touch D9 button for turn off the Electromagnet
// Touch White or Black button for set the polarity of the Electromagnet
// 
// 
// 


#include <Wire.h>


//  Electromagnet H Bridge L298
int IN1 = (14);
int IN2 = (15);
int MAGNET (6);  // Enable or not the H-Bridge

// **** Add new Variables for this test
// Define el rango del PWM del Electroiman | Define the PWM range of the electromagnet
    const int pwmMax = 255;  // Valor máximo para el PWM | Maximum value for the PWM
    const int incrementDelay = 10;  // Retraso para el incremento de PWM | Delay for the PWM increment
//    const int holdTime = 500;  // Tiempo en milisegundos para mantener el PWM al máximo | Time in milliseconds to hold the PWM at maximum
    bool state = false;

enum sequence {D16_Turn_ON,D9_Turn_OFF,D11_White_EM,D10_Black_EM,none};
sequence mySequence;


//  Button - Switch
const byte BUTTON_WHITE_SWITCH_MOTOR_WHITE (11);
const byte BUTTON_BLACK_SWITCH_MOTOR_BLACK (10);
const byte BUTTON_9 (9);
// const byte BUTTON_8 (8); Not used in this Test
const byte BUTTON_16 (16);

// ****************************************  SETUP
void setup() {
  Serial.begin(9600);
Serial.print("Instructions");
Serial.println(" ");
Serial.println("With no Power, put the pieces on the board");
Serial.println(" ************** ");
Serial.println("Power on");
Serial.println(" ");
Serial.println("No Motor Coded here, so you have to move by hand the Trolley with the Electromagnet."); 
Serial.println("D16 button is for turn on the Electromagnet");
Serial.println("D9 button is for turn off the Electromagnet");
Serial.println("D11 (White Button) button for set the polarity of the Electromagnet for White Pieces");
Serial.println(" ");
Serial.println("D10 (Black Button) button for set the polarity of the Electromagnet for Black Pieces");
Serial.println(" ");
Serial.println(" ************** ");


//  Electromagnet
  	pinMode(IN1, OUTPUT);
  	pinMode(IN2, OUTPUT);	
		pinMode (MAGNET, OUTPUT);


//  Arcade button - Limit Switch
  pinMode (BUTTON_WHITE_SWITCH_MOTOR_WHITE, INPUT_PULLUP);
  pinMode (BUTTON_BLACK_SWITCH_MOTOR_BLACK, INPUT_PULLUP);
  pinMode (BUTTON_9, INPUT_PULLUP);
 // pinMode (BUTTON_8, INPUT_PULLUP); // Not Used in this test
  pinMode (BUTTON_16, INPUT_PULLUP);

// Secuencia de Inicio | Start Sequence

mySequence = none; // inicio en None | start in None
// Initial set for Black Piece
  digitalWrite(IN1, HIGH); // Change for invert Polarization
   digitalWrite(IN2, LOW);  // Change for invert Polarization
   
} // Close Set Up


// *****************************************  LOOP
void loop() {
// D16_Turn_ON,D9_Turn_OFF,D11_White_EM,D10_Black_EM,none
// BUTTON_WHITE_SWITCH_MOTOR_WHITE
// BUTTON_BLACK_SWITCH_MOTOR_BLACK
// Verifico Presion de Botones para cambios de secuencia | Checking Button Press for sequence changes

if (digitalRead(BUTTON_16) != HIGH) { 
  mySequence = D16_Turn_ON;  
  }
if (digitalRead(BUTTON_9) != HIGH) { 
  mySequence = D9_Turn_OFF;  
  }
if (digitalRead(BUTTON_WHITE_SWITCH_MOTOR_WHITE) != HIGH) { 
  mySequence = D11_White_EM;  
  }
if (digitalRead(BUTTON_BLACK_SWITCH_MOTOR_BLACK) != HIGH) { 
  mySequence = D10_Black_EM;  
  }
switch (mySequence){

	case D16_Turn_ON:
		Serial.println("D16 Pressed. Electromagnet Will Turn On");
	electromagnet(true);
  break;
  
  case D9_Turn_OFF:
    Serial.println("D9 Pressed. Electromagnet Will Turn Off");
  electromagnet(false);
  break;

	case D11_White_EM:
		Serial.println("White Button (D11) Pressed. Electromagnet Will put Polarity for White Pieces");
	// set polarization for White
  digitalWrite(IN1, LOW); // Change for invert Polarization
   digitalWrite(IN2, HIGH);  // Change for invert Polarization
	break;

  
  case D10_Black_EM:
    Serial.println("Black Button (D10) Pressed. Electromagnet Will put Polarity for Black Pieces");
  // set polarization for Black
  digitalWrite(IN1, HIGH); // Change for invert Polarization
   digitalWrite(IN2, LOW);  // Change for invert Polarization
  break;
  
	case none:

	break;

} // close switch

// Aquí es donde el código esperará por la pulsación de un botón | This is where the code will wait for a button press
  if (mySequence != none) {
    Serial.println("**** Waiting for Button Press (D9 or D8 or White or Black) ****");
    while (digitalRead(BUTTON_16) == HIGH && digitalRead(BUTTON_9) == HIGH && digitalRead(BUTTON_WHITE_SWITCH_MOTOR_WHITE) == HIGH && digitalRead(BUTTON_BLACK_SWITCH_MOTOR_BLACK) == HIGH) {
      delay(100);  // Pequeña pausa para evitar sobrecargar el procesador | Small pause to avoid overloading the processor
    }
  }

} // close loop



// *******************************  ELECTROMAGNET H-Bridge 
void electromagnet(bool state) // For this Test
{
	Serial.print("Electroiman | Electromagnet ");
	Serial.println(state ? "Encendido | ON" : "Apagado | OFF");
	

	if (state == true)  // For this Test
	{
	 for (int pwmValue = 0; pwmValue <= pwmMax; pwmValue++) { // Agrege incremento suave, en lugar de ir directo al valor para ver si ayuda a evitar que las piezas salgan de su posicion al encender el EM | Added smooth increment instead of going directly to the value to see if it helps prevent the pieces from moving out of position when the electromagnet is turned on
            analogWrite(MAGNET, pwmValue);
            delay(incrementDelay);  // Espera antes de incrementar el PWM | Wait before increasing the PWM
        }
 //   delay(holdTime);  // Mantén el PWM al máximo durante el tiempo especificado | Keep the PWM at maximum for the specified time
        
	}
	else  
	{
		//delay(100);
		digitalWrite(MAGNET, LOW);
	}
}

I don't see a use of pin 13. On my official Mega the L-LED will be on when it's not controlled; not exactly sure why (it's controlled by an opamp).

On you Mega, it might be on for one of two reasons

  1. No damage was done and hence it behaves as expected.
  2. The LMV358 was killed.

Throw the board away. Even if it still partially works, it will be unreliable and one day it will die and you will not understand why your project no longer works.

Note
I have experience with ESD and lightning as slow killers of electronics and 12V can be a similar slow killer.

To clarify, the pin used was pin 15, not pin 13. This code is merely a test to check if the components are functioning as expected. If it works, I can use it for my testing purposes and reserve the new Mega for the actual project.

OK From an earlier reply (that I forgot about), your 2560 might currently still be in a working state.

If that works and your board has the 8U2 or 16U2 as the serial-to-usb converter (neither is likely for a clone), you can try to flash the firmware for that; see https://support.arduino.cc/hc/en-us/articles/4408887452434-Flash-USB-to-serial-firmware-in-DFU-mode.

If your board doesn't have the 8U2 or 16U2, buy a serial-to-usb adapter that has the DTR pin broken out; e.g. https://www.sparkfun.com/products/9716 as already mentioned. Or buy a programmer like Pololu USB AVR Programmer v2.1 which includes a serial-to-usb converter as well.

And try to upload using that.

That's how far I can help.

How would I know whether my board has 8U2 or 16U2 as the serial-to-usb converter?

It's printed on the chip closest to the USB connector. Clones usually have the CH340.

Another giveaway is the presence of a 6-pin header close to the USB connector (not the one that is more ir less in the centre of the board).

That does not really matter. The point was the behaviour of the built-in LED.

The broken Mega doesn't use a CH340, i think its a atmega2560 as it is squarish shape.

I said "closest to the USB".

image

The one I circled in red, right? If so, then it is the same as the one that is broken Mega
1726644117713

Yes. See first link in post #29.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.