Start Up Arduino With specific Sketch

Hello,

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.

This is confusing and I hope there is a solution.

Thanks in advance for your help!

Have you got a number of different sketches that you want to start with automatically or just one ?

I assume that you know that you can open one of a number of recent sketches from the IDE menu

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.

Or, if you had an Arduino with the larger RAM and code storage you could load them all in your Arduino and run a sketch swapper kinda' thing.

But I wonder how many/large these sketches are?

-jim lee

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.

-jim lee

Sometimes it crashes. Quite annoying.

welcome to the world of Java.
You know the thing about interpreters and compiler is that they both have their disadvantages, and Java is both !

UKHeliBob:
Have you got a number of different sketches that you want to start with automatically or just one ?

I assume that you know that you can open one of a number of recent sketches from the IDE menu

Hi,
Just one sketch. I forgot to say that I am running windows10.
Thanks

What happens when you double click on a .ino file in File Explorer ?

When I double click on a .ino file it opens in Arduino

Techhack:
When I double click on a .ino file it opens in Arduino

Then there is your answer to

What I am looking for is how to start up Arduino with a specific Sketch loaded and ready to run.

Now just to create a shortcut on the desktop to that file..

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.

Techhack:
What I am looking for is how to start up Arduino with a specific Sketch loaded and ready to run.

Sketches are not "run" on the Arduino IDE, they are run on the target board's processor.

The IDE is used to edit and compile sketches and download them to the target processor.

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.

Hopefully this will clarify.

Thanks in advance...

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

It does. Why don't you try it ?

Here is the batch file I am using

@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?

This is very frustrating.

Thanks for your help!

Techhack:

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.