Question about getting code off of Arduino Uno

Hello

I had wrote a sketch for my arduino uno and uploaded it to the uno but then I accidentally erased the sketch from my computer, is there a way to read the code back from the arduino into a sketch again? does that make since? Thanks

LongDog: Hello

I had wrote a sketch for my arduino uno and uploaded it to the uno but then I accidentally erased the sketch from my computer, is there a way to read the code back from the arduino into a sketch again? does that make since? Thanks

Well it's possible to get back the raw binary code of the program using a ISP programmer and using command line control of the AVRDUDE program. However that will be raw AVR machine code, not the C++ sketch code you wrote it in. So probably not worth the effort even if you have the required AVR assembly language skills. Easier to just rewrite your sketch from scratch. Lesson learned is to make frequent back ups of all your PC files.

Lefty

No, you cannot do what you ask. Best you can do is download & save the hex file. With a lot of work, you could get assembly language code.

Generally quicker just to recreate what you had. Make sure to save someplace safer.

How do you actually pull it off? I cant seem so find out how anywhere. I want to copy the program off a micro processor to then put that exact code on another. I am fairly new to this so in the simplest form possible would be greatly appreciated.

There was something on the Playground about something that would read its own flash and copy it to another chip. The easiest way would probably be to use avrdude to read the hex file and store it somewhere. AVRDUDESS is a nice GUI for avrdude that makes it easy to read a hex back from a chip and then write it to another. https://github.com/zkemble/AVRDUDESS