I had a big (ish) load of code written out, and uploaded to a Uno. All Great. I did that quite a while back now.
The other day, i wanted to modify the code, but i didn't know if my modification would muck everything up, so, incase it did, instead of editing it all back to the last working iteration, i did what seemed best, and duplicated the .ino file (Just Ctrl+c Ctrl+V), so i had myfile.ino, and myfile - Copy.ino. In the same folder.
So off i went, edited the "copied" one, and then ended up abandoning the edit. However, i had saved it, and i forgot how the IDE seems to work with folders, not individual files. So, all the messing around i did in the copy, is now saved to my "proper" code also. That means i don't have a copy of the working code anywhere, EXCEPT on the arduino itself.
So, if that makes any sense, is there a way to read the code FROM the arduino, into the IDE, where i can save it, work on it, etc, instead of starting over? .
The code you wrote is gone. It does not get uploaded to the Uno, you cannot get it back from there. What gets uploaded is the compiled version which does not resemble your original code in any decipherable way. Sorry.
With other (non-Arduino) boards, you might write your code in Python, and it gets uploaded to the board in its original state, and you can download it again and continue working on it. But Arduino code is C/C++, not Python and only the compiled binary machine code is uploaded to the board. If this seems like a terrible disadvantage, remember that the compiled C/C++ code is a tiny fraction of the size and runs 20x faster on the same board than the equivalent Python code. Traditional 8-bit Arduino cannot run Python code at all, they don't have the capacity or speed to do it. But they can run C/C++ code as fast as 32-bit boards can run equivalent Python code.
The process of compiling translates human readbale text of the *.ino-file and all *.h and *.cpp files into assembler-code which is machine-readable by the microprocessor but no longer human readable.
Only in case the US secret-service would catch a russian or chinese drone would take the effort of reverse-engineering from the compiled code to its functionality. And this process would take 20 very talented software-developpers years to do it.
So invest 1 or 2 hours in setting up a system of new to train behaviour and automated backups to not get into such a situation again.
Me personal I simply use the save-as.... option and change a serial-number at the end of the filename
ESP32-Weather-Station-001.ino
ESP32-Weather-Station-002.ino
ESP32-Weather-Station-003.ino
.....
my computer doesn't care that there are now 4578 *.ino files in summary
with all examples-codes for a lot of different platforms like Uno, Mega, ESP8266, ESP32 XIAO, Teensy etc.
Does myfile.ino still exist? What is left in the folder?
Learn to use github. Even if you don't use it for version control, at least you will have a backup if your harddrive crashes.
Also, post your code here. As an example to others to look at. You'll be glad you did when you blow your code away again and recall that you haven't pushed to github in a while.
Each time I reach a working milestone I up the _00 number. This way if I hose the code I can always go back a revision. I used to use ZIP files with the backup but the above works better for me.
Hello,
Thanks for all the reply's, very informative.
i will do as you advise, and re-write the code, as i do have A version left, just not the latest with all features. Shouldn't take too long... Also, JohnRob, that was basically what i was doing with my "Copy" version, but i did not put it in a separate folder, so screwed the working version up...