Software download from mega

I have a program running on the Arduino mega 2560 , I did't save it. Is there a way to download it from the mega to ide?

Remember when you COMPILED the program before uploading it to the Arduino? Your SOURCE code was NOT uploaded, the compiled machine code was uploaded and that is what runs the Arduino. Sorry.

No

The sketch has been compiled to a binary file and uploaded to the Mega. The source code no longer exists unless you saved it and the binary file cannot be reconstituted back into a sketch

The binary file itself can be downloaded but you cannot then edit it in the IDE

Thanks I guess I new that but was hoping

| Paul_KD7HB
August 26 |

  • | - |

Remember when you COMPILED the program before uploading it to the Arduino? Your SOURCE code was NOT uploaded, the compiled machine code was uploaded and that is what runs the Arduino. Sorry.

CAVEAT: The temp folder only exist until the ArduinoIDE is closed - then the IDE cleans-up the temporary directory.

When you compile/compile-upload, the build process does a lots of preprocessing... you can research that on your own. But, lots of code: manipulated sketch, core, libraries get transferred to a temporary directory, location depends on how ArduinoIDE was installed. But, no matter, if you have ArduinoIDE Preferences are set to Verbose, Arduino will identify the location.

Example:


"C:\\Users\\burne\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-gcc-ar" rcs "C:\\Users\\burne\\AppData\\Local\\Temp\\arduino_build_60704\\core\\core.a" "C:\\Users\\burne\\AppData\\Local\\Temp\\arduino_build_60704\\core\\wiring_digital.c.o

The part I'm interested is in bold:

"C:\Users\burne\AppData\Local\Temp\arduino_build_60704\core\wiring_digital.c.o

Looking on my Win-11 machine:

The important folder is sketch

The file of interest is: Blink_Count.ino.cpp

#include <Arduino.h>
#line 1 "C:\\Users\\burne\\Documents\\Arduino\\Ray_Sketches\\UNO\\Tests\\Blink_Count\\Blink_Count.ino"
/*
  Blink
  Turns on an LED on for one second, then off for one second, repeatedly.
 
  This example code is in the public domain.
 */
int n = 0;

#line 9 "C:\\Users\\burne\\Documents\\Arduino\\Ray_Sketches\\UNO\\Tests\\Blink_Count\\Blink_Count.ino"
void setup();
#line 17 "C:\\Users\\burne\\Documents\\Arduino\\Ray_Sketches\\UNO\\Tests\\Blink_Count\\Blink_Count.ino"
void loop();
#line 9 "C:\\Users\\burne\\Documents\\Arduino\\Ray_Sketches\\UNO\\Tests\\Blink_Count\\Blink_Count.ino"
void setup() {                
  // initialize the digital pin as an output.
  // Pin 13 has an LED connected on most Arduino boards:
  pinMode(13, OUTPUT);
  Serial.begin(9600);
  Serial.println("Blink LED & count Demo");
}

void loop() {
  digitalWrite(13, HIGH);   // set the LED on
  delay(500);              // wait for a second
  digitalWrite(13, LOW);    // set the LED off
  Serial.print("Loop #: ");
  n++;
  Serial.println(n);
  delay(500);              // wait for a second
}

The original .ino file:

/*
  Blink
  Turns on an LED on for one second, then off for one second, repeatedly.
 
  This example code is in the public domain.
 */
int n = 0;

void setup() {                
  // initialize the digital pin as an output.
  // Pin 13 has an LED connected on most Arduino boards:
  pinMode(13, OUTPUT);
  Serial.begin(9600);
  Serial.println("Blink LED & count Demo");
}
void loop() {
  digitalWrite(13, HIGH);   // set the LED on
  delay(500);              // wait for a second
  digitalWrite(13, LOW);    // set the LED off
  Serial.print("Loop #: ");
  n++;
  Serial.println(n);
  delay(500);              // wait for a second
}

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