Failed to upload sketch and Tx Rx light is not glowing

/usr/local/bin/arduino-cli compile --fqbn arduino:avr:mega:cpu=atmega2560 --libraries /home/builder/opt/libraries/latest --build-cache-path /tmp --output-dir /tmp/738095699/build --build-path /tmp/arduino-build-E43705BC838D7345A0FA9542BE6FF6FE /tmp/738095699/sketch_apr24a

Sketch uses 2748 bytes (1%) of program storage space. Maximum is 253952 bytes.

Global variables use 200 bytes (2%) of dynamic memory, leaving 7992 bytes for local variables. Maximum is 8192 bytes.

Upload started

Programming with: Serial

Flashing with command:C:/Users/Subhankar/.arduino-create/arduino/avrdude/6.3.0-arduino17/bin/avrdude.exe -CC:/Users/Subhankar/.arduino-create/arduino/avrdude/6.3.0-arduino17/etc/avrdude.conf -v -patmega2560 -cwiring -PCOM9 -b115200 -D -Uflash:w:C:/Users/SUBHAN~1/AppData/Local/Temp/arduino-create-agent744230509/sketch_apr24a.hex:i

avrdude: Version 6.3-20190619

Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/

Copyright (c) 2007-2014 Joerg Wunsch

System wide configuration file is "C:/Users/Subhankar/.arduino-create/arduino/avrdude/6.3.0-arduino17/etc/avrdude.conf"

Using Port : COM9

Using Programmer : wiring

Overriding Baud Rate : 115200

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

avrdude done. Thank you.

How to fix this?

Could be any number of things. Wrong board selected, Something attached to the serial pins, bad cable...

Did it work in the past?
Is COM9 indeed the Mega?
What is the TTL-to-USB converter onthe board?
What is your project about?

/

// This code is based on 14 coils 5 sets (5 8j Hallpin and 5 Transpin).
// Code is developed by Subhankar Chakraborty.
// Do not copy this code, it may leads to accident.
// Code never lies..

// defines variables
long duration;
int distance1=0;
int distance2=0;
int distance3=0;
float Acceleration;
double Speed1=0;
double Speed2=0;
double Speed3=0;
int distance=0;

//Declaring the pins for Hall effect sensor:

int Zero_Value = 0; 
int Hallpin1 = 2; // Hall effect sensor pin
int Hallpin2 = 23; // Hall effect sensor pin
int Hallpin3 = 27; // Hall effect sensor pin
int Hallpin4 = 6; // Hall effect sensor pin
int Hallpin5 = 7; // Hall effect sensor pin
//const int trigPin = 12; // Ultrasonic Sensor pin
//const int echoPin = 13; // Ultrasonic Sensor pin

// Declaring the pins for Mosfet(Transistor):

int Transpin1 = 22; // Mosfet pin
int Transpin2 = 24; // Mosfet pin
int Transpin3 = 26; // Mosfet pin
int Transpin4 = 11; // Mosfet pin
int Transpin5 = 12; // Mosfet pin

//Declaring the initial state for Hall effect sensor:

int Hallstate1 = 0;  // Setting the initial value for Hall effect sensor
int Hallstate2 = 0;  // Setting the initial value for Hall effect sensor
int Hallstate3 = 0;  // Setting the initial value for Hall effect sensor
int Hallstate4 = 0;  // Setting the initial value for Hall effect sensor
int Hallstate5 = 0;  // Setting the initial value for Hall effect sensor

//The main setup

void setup(){
  Serial.begin(9600);
  pinMode(Hallpin1, INPUT); //Asking arduino to take the value of this pin as input
  pinMode(Hallpin2, INPUT); //Asking arduino to take the value of this pin as input
  //pinMode(Hallpin3, INPUT); //Asking arduino to take the value of this pin as input
  //pinMode(Hallpin4, INPUT); //Asking arduino to take the value of this pin as input
  //pinMode(Hallpin5, INPUT); //Asking arduino to take the value of this pin as input
  pinMode(Transpin1, OUTPUT); //Asking arduino to give the output of the respective pin
  pinMode(Transpin2, OUTPUT); //Asking arduino to give the output of the respective pin
  //pinMode(Transpin3, OUTPUT); //Asking arduino to give the output of the respective pin
  //pinMode(Transpin4, OUTPUT); //Asking arduino to give the output of the respective pin
  //pinMode(Transpin5, OUTPUT); //Asking arduino to give the output of the respective pin 
}

/*float ultrasonicRead ()
{
  // Clears the trigPin
  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);

  // Sets the trigPin on HIGH state for 10 micro seconds
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(100);
  digitalWrite(trigPin, LOW);

  // Reads the echoPin, returns the sound wave travel time in microseconds
  duration = pulseIn(echoPin, HIGH);

  //calculating distance
  distance= duration*0.034/2;
  
  Serial.print("Acceleration in cm/s2 : ");
  Serial.println(Acceleration);
  return distance;
}
*/
//Looping the main setup

void loop(){
  Hallstate1 = digitalRead(Hallpin1); //Reading the initial state and if there any change in state
  Hallstate2 = digitalRead(Hallpin2); //Reading the initial state and if there any change in state
  //Hallstate3 = digitalRead(Hallpin3); //Reading the initial state and if there any change in state
  //Hallstate4 = digitalRead(Hallpin4); //Reading the initial state and if there any change in state
  //Hallstate5 = digitalRead(Hallpin5); //Reading the initial state and if there any change in state
  //Serial.print(Hallstate1);
  //Serial.println();

  /*//calculating Speed
  distance1 = ultrasonicRead(); //calls ultrasoninicRead() function below
  delay(100);//giving a time gap of 0.1 sec
  distance2 = ultrasonicRead(); //calls ultrasoninicRead() function below
  delay(100);
  distance3 = ultrasonicRead();
  
  Serial.print("Distance1 in cm  :"); 
  Serial.println(distance1);
  Serial.print("Distance2 in cm  :"); 
  Serial.println(distance2);
  Serial.print("Distance3 in cm  :"); 
  Serial.println(distance3);


    
  //formula change in distance divided by change in time
  Speed1 = (distance2 - distance1)/0.1; //as the time gap is 1 sec we divide it by 1.
  Speed2 = (distance3-distance2)/0.1;
  Speed3 = (distance3-distance1)/duration;
  //acceleration
   
  Acceleration = ( Speed2-Speed1)/2;
   
  //Displaying Speed
   
  Serial.print("Speed in cm/s  :"); 
  Serial.println(Speed1);*/
  

  if (Hallstate1 == LOW){
    digitalWrite(Transpin1, HIGH);
    Serial.print("Detected1");
    //delay(100);
    Serial.println();
  }
  /*else if (Hallstate2 == LOW){
    digitalWrite(Transpin2, HIGH);
    Serial.print("Detected2");
    delay(5000);
    Serial.print("done");
    Serial.println();
  }
  /*else if (Hallstate3 == LOW){
    digitalWrite(Transpin3, HIGH);
    Serial.print("Detected3");
    Serial.println();
  }*/
  /*else if (Hallstate4 == LOW){
    digitalWrite(Transpin4, HIGH);
    Serial.print("Detected4");
    Serial.println();
  }
  else if (Hallstate5 == LOW){
    digitalWrite(Transpin5, HIGH);
    Serial.print("Detected5");
    Serial.println();
  }*/
  else{
    digitalWrite(Transpin1, LOW);
    digitalWrite(Transpin2, LOW);
    //digitalWrite(Transpin3, LOW);
    //digitalWrite(Transpin4, LOW);
    //digitalWrite(Transpin5, LOW);``
  }
}

I'll check on cable tomorrow...

Please edit your post, select all code and click the </> button to apply code tags. Next save your post.

This makes it easier to read and copy and prevents the forum software from interpreting your code as instructions for thr form software.

Read the forum guidelines to see how to properly post code and some good information on making a good post.
Use the IDE autoformat tool (ctrl-t or Tools, Auto format) before posting code in code tags.

You can go back and fix your original post by highlighting the code and clicking the </> in the menu bar.
code tags new

1 Like

Thank you.

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