Can I tell the IDE which board to use in the sketch?

I am working on a project that has multiple Arduino's in it.

I have a Mega2560 and an Uno that I have communicating with each other via I2C.

I have the code for each open in a copy of the IDE.

When I want to change to down load to the "other board" I need to change the Board and the Port in the tools menu. Sometimes I forget!

Since the code in each sketch is dedicated for one board or the other can I tell the IDE which board and port to use in the sketch?

I think I remember that in the past if I had 2 IDE's open that each remembered its own board and port, but some update ago they started both having the same board and port so that changing one changed the other.

I also used to be able to have 2 serial monitors open looking at different ports. Can I get back to that too?

(Using PC with version 1.6.5)

Thanks Gareth

I have written a Python program to manage the compiling and uploading. The type of board is entered as a comment at the top of the Arduino program. Feel free to use it if it helps. It is attached to the Post in this link

...R

Thanks, I'm not familiar with python so that is not a route I'd like to go down.

I guess I'll just have to remember to set my board and port!

Thanks

Gareth

Along similar lines is ino. You will still have to sacrifice the familiarity of the IDE but you can put all the defaults for each sketch in an ini file so everything is largely automated.

You can use putty as a serial comms monitor if you need to run more than one serial session.

GarethMoffatt: Thanks, I'm not familiar with python so that is not a route I'd like to go down.

It should not be difficult to implement the same idea in any other language.

...R