I have a number of sketches that were written for Arduino and they work fine. Currently I start Arduino, then navigate to the Sketchbook and click the sketch I want to run. What I am looking for is how to start up Arduino with a specific Sketch loaded and ready to run. In other applications things like a command line switch would be used. I have searched and all I find is how to start Arduino and do things.
From Linux command line I can go (for example):
/home/username/arduino-1.6.5-r5/arduino /full pathname to file &
On my computer:
/home/me/arduino-1.6.5-r5/arduino[SPACE]/home/me/sketchbook/blink_D/simpleBlink/simpleBlink.ino &
I'm sure you could do the same in Win or Mac. You could make up a menu with a simple shell script or batch file or get fancy with a GUI version.
The same as JCA34F said works fine in Windows as well.
If you have .ino files associated with the Arduino IDE (as happens when you use the Windows installer, and I believe the Linux install.sh as well), then just opening a .ino file will start the IDE with it open, so you don't even need to set up the commands using the path to the Arduino IDE executable.
IDE version 1.6.5 didn't start up with the sketch you closed with (don't know how that happened it was working in earlier versions) but in version 1.8.x when you quit the IDE from the File menu, all windows close and when you start the IDE up again all those windows will open again. (just like it did before) If you just close the windows one by one, just the last window you closed will open up. (all of this unless you click to open a specific INO file of course.) It really annoyed me at times in v1.6.5 so i looked for a setting in preferences but i somehow never got it to work.
1.18.12 (MacOS) Many times you click close on the windows, say save or not to save, and it just leaves them on the desktop ignored. Sometimes it crashes. Quite annoying.
The original question is not clear as to whether the requirement is to load the code ready to compile and upload it to the Arduino or to automate this in some way so that the code is loaded, compiled and uploaded automatically. Hopefully the former
I'm wondering if the OP has a misapprehension and believes that when you power up the Arduino you need to reload it with a sketch. This because he mentions having only one to load.
Here is what I am trying to do. I have a batch file which loads a number of files including Excel, and Arduino. For Excel I can use a command line switch to open excel and a designated workbook. I was asking if Arduino had the same capability. If not then I need an alternate idea.
@echo off
cd "C:\Program Files (x86)\Microsoft Office\Office12\Excel.exe"
start Excel.exe "C:\Users\ANAME\Documents\Excel Files\Health Data\Blood Pressure.xlsm"
cd "%ProgramFiles(x86)%\Windows Media Player\wmplayer.exe" /prefetch:1
start wmplayer.exe
cd "C:\Program Files (x86)\Arduino\Vibrate6p17\Vibrate6p17.ino"
start Arduino.exe Vibrate617
exit
I have tried everything I can think of to get Arduino to start sketch Vibrate6p17.ino but noting seems to work. Is there some special way to write the command line entry? When I run the bat file everything does fine but Arduino opens without finding the sketch.
How do you get this to work? Is it documented someplace?
cd "C:\Program Files (x86)\Arduino\Vibrate6p17\Vibrate6p17.ino"
"cd" stands for "current directory", so the argument must be a directory. I'm guessing that "C:\Program Files (x86)\Arduino\Vibrate6p17\Vibrate6p17.ino" is a file not a directory. If so, then that line should be:
cd "C:\Program Files (x86)\Arduino\Vibrate6p17"
You actually don't need to cd to the directory. You can specify the full path to the .ino file.
Techhack:
start Arduino.exe Vibrate617
Unfortunately, the sketch argument to arduino.exe is a file not a directory. So this line should be:
start Arduino.exe Vibrate617.ino
If also appears from your previous command that the file should be "Vibrate6p17.ino", not "Vibrate617.ino"
Another thing is that if you have .ino files associated with the Arduino IDE, you can simply run the .ino file directly without specifying the Arduino IDE executable. However, you may prefer to use your current approach if you later decide to associate .ino files with a different program, but still want your batch file to open the file in the Arduino IDE.