How to assign a job to the correct calculate?

I have a multi-Tabs sketch as pictures shown, that works in the way as:
The AnalogRead read A0-5 value and assign the job to the right calculator in the different Tabs based on the reading pin. say if there is a reading from A4 need the calculate at Tab1, and A5 to Tab2.
Need help how to do with this please.


Tabs with ino extension are combined into one file before compiling.
They don't give you more than one setup and or loop structure.

1 Like

I made them as: Tab1_setup / Tab1_loop ....
Can I do like this:

if (A4 > 50)
if (A5 > 25)

You can name functions as you like,
but giving them names that carry some meaning is much better.

What will Tab2_loop mean to you in a year from now?

1 Like

A4 is a constant and has the value 18 on an UNO, A5 has the value 19.

1 Like

The Tab1 do current calculate, and the Tab2 do voltage calculate.

So would calculateCurrent not be a better name for the function?
It could even return the result.

1 Like

Well, the Threshold is set meaningful, if A4<50, and A5<25, no need do any thing.

They are constants. The names/numbers of the analog pins.

1 Like

This is just a principle display, the real calculation got thousand lines code for them each.
The Ai reading can change when the input value changes.

It's just a very bad example.

if (anologRead(A4) < 50) {

would be better.

I doubt that.