uploding and down loading sketch.

I've uploaded source code to Arduino Mega board using Sketch. After that, I modified the original code. And later I needed the original code which was not modified for the other board, but I didn't back it up.

Is there any way I can download the source code from the board that I uploaded before?

No. If you didn’t save the Source code (meaning the C++ code you wrote in the IDE) on your PC, it is gone.
Save-As often, renaming as you go, can be a simple letter change at the end:
Test1, Test1a, Test1b, etc. and add a
/* comment line */
at the top of your sketch with a note about what is different in that particular rev.

If you mean the compiled .hex file that was uploaded to the Arduino, you can search your hard drive for the Temp/Build folder that was created when the file was compiled and find the one that matches the date & time you created it. Open File:Preferences, select Verbose Outputs. Compile a simple program, when done scroll back thru the output and find the folder path to see where they are being stored.

I think you can use avrdude commands to upload that file to an arduino, I’ve never done it myself.

It is able also download HEX using avrdude commands from programmed Arduino and use it for another but not the source code. Sorce code from HEX only with reverse engineering. Source code could be saved in temporary folder. Each time is created new temporary folder whenever IDE is started

Thanks dudes.. finally it means i have lost my source, and no way to get it back. :( k. i will keep it in mind from now to save my codes without forgetting..

On the plus side, rewriting it the 2nd time is usually faster as you have already done a lot of the thinking that goes into it with the first writing. 8)

but I didn't back it up.

:'( I suspect we have all done this at least once.

The positive from this is you will not do this again, hopefully.

I use syncBack for auto backups to two different hard drives. http://www.2brightsparks.com/freeware/freeware-hub.html?gclid=CO7qgo-14sQCFQ8oaQodTRMAvQ Don't use the Synchronize mode so when you delete a file on the source it still stays on the destination. .

The positive from this is you will not do this again, hopefully.

:grin: He will do this again, I'm sure.

On the OpenVMS operating system there is file version numbering feature. A new version of file is created automatically by file system whenever you save the file. It is very easy to return back to the previous one. I'm using this manner to add the number manually file_name#000*.cpp* (on Windows) for older versions but sometimes I forget. 8)