While loops

Two questions then.

Can you put 'return' inside a 'while loop' or must it wait until the loop closes?

The second question is similar. Can you call a function inside a function? (that's not the same as defining a

function is it?)

Yes you can put a return in your loop and yes you can call another function inside another.
You’ve been doing the latter for a while.

Yup! One of those days I'm afraid!!!

I don't know if this is the right forum for the next question.
Can two Nanos be run in tandem? I'm running out of inputs and though I have a Mega the Nano fits my requirements dimensionally.

Define "tandem"

How many inputs do you need ? Have you used all of the analogue inputs or could you use some of them as digital inputs ? Could you use an analogue input and resistor ladder to read multiple switches ? What sensors are connected to the inputs ?

More details of the problem please.

Tandem? I mean running the same sketch in synchronization on two Nanos. The result being to increase the number of inputs/outputs.

I have one digital and two or three analog inputs remaining. The use of a resistor ladder sounds interesting would you suggest code? However I have only three switches and that would save only two inputs. I'm thinking ahead here!

he use of a resistor ladder sounds interesting would you suggest code?

If you do a search for resistor ladder in the forum you should get plenty of hits. The basic principle is simple in that each switch produces a different voltage on the analogue pin so produces a different value from analogRead() which allows you to determine which switch has been pressed.

Sacrifice 2 or 3 pins and you can get a (theoretically) unlimited number of pins back. I2C port expanders, SPI devices or simple serial in / parallel out (or vice versa) shift registers.

See e.g. the MCP23017/MCP23S17

Running the same sketch in tandem is silly. You can of course offload some of the work to the other nano and have it communicate with the other to report results. Much lie sterretje's port extender, but with intelligence.

I’m trying not to be silly, KeithRB. I’m a beginner at this and so I ask questions to improve my knowledge. Please point me in the direction of information on doing what you suggest. I could use one Nano to read sensors and switches and the other to do the nitty-gritty, I suppose.

I do use the I2C port and another pin as oneWire because some of the sensors require it and hadn’t considered using it as you describe, I’ll look into that sterretje - thanks.

Exactly, they can connect through a serial line.

Maybe silly was a bit strong, but if you have two nano's running the same program, how do they report the data? Use two serial ports on the PC?