Good afternoon,
I teach technology k-6 and work with Arduinos with my 6th graders, and also 4th-8th graders for summer enrichment - robotics. Using a lab with shared computers, students are often inadvertently editing, deleting or overwriting other student's code because the IDE automatically opens to the previously opened sketch. I can't find any way to have Arduino open to a blank/new or at least example code vs. another student's saved sketch. Is this an option that could be added?
Thanks,
Mrs. Weber, tech teacher
There may be a more elegant method but:
Set the file:
C:\Users\john\AppData\Roaming\arduino-ide\config.json
(where "john" is the user name the machine was logged in to.)
to read only. It will retain the currently opened file and not update to the last opened file. It will give you a Java error but I've tested it a number of times and it seems to do the job.
Can you show them to click FILE->Examples or Sketchbook?
Also how to SaveAs to a flash drive? In bulk, 8G sticks are cheaper!
Tell those kids for me that making effort is a good habit to practice!
Hi @jweberTech. You can add a sketch path as an argument to the Arduino IDE invocation. If you do that, Arduino IDE will open that sketch instead of restoring the sketches that were open at the time of exit of the previous IDE session.
For example, if you are using Windows, you can do this:
- Right click on the Arduino IDE executable.
A context menu will open. - Select "Show more options" from the menu.
- Select Send to > Desktop (create shortcut) from the menu.
A shortcut will be added on the Windows Desktop. - Right click on the shortcut.
A context menu will open. - Select "Properties" from the menu.
A "Shortcut Properties" dialog will open. - Click on the "Target" field in the dialog.
- Type the path to the default sketch at the end of the existing content of the field.
For example, if the original content of the field is this:
And the folder of the sketch you want to open by default is at this path:"C:\Program Files\Arduino IDE\Arduino IDE.exe"
Then you would change the "Target" field to this:"C:\Sketches\Default"
"C:\Program Files\Arduino IDE\Arduino IDE.exe" "C:\Sketches\Default"
- Click the "OK" button in the dialog.
If the students use that shortcut to start Arduino IDE, it will now open the sketch at the path from the argument.
You can set the "read-only" file attribute of the default sketch if you want to prevent the students from modifying it. If they attempt to do so, the IDE will display a "Cannot edit in read-only editor" tooltip when they attempt to edit (or some similar behavior if you are using Arduino IDE 1.x)
I think that it makes more sense to use Save As or New and control what is in the Sketchbook folder. Then regardless of OS, the IDE keeps things straight.. but that
s just me and my opinion!
Sketchbook location is at the top of File->Preferences.