Arduino Multitasking?

Hello
I'm new to programming and the Arduino world.
I already learned the basic functions, but the more I learn, more it sems to me that one Arduino won't fulfill the job I need it to do on my project.

For exemple, I want to make a Arduino to monitor some sensors, send it to a ethernet server (which will be hosted in a RaspberryPi). But I also want it to control some outputs (lights, motors, etc), via the information of the sensors plus manual activation from a device connected to the network.

My question is, how can I make the Arduino put a 1 on port X1 if it receives order Y1 from the RaspPi or do the same if it detects that its below 10 degrees from a temp sensor; and in the same time, be able to receive order Y2 and activate port X2, order Y3 port Y3, etc. (X1, Y1, X2... are exemples)

By my current understandment of programming, that would require several "if"s, one for each order. But afaik the Arduino can only process one thing at a time, if it's wating for the
if (Y1 == high) {digitalWrite (X1,HIGH)};
to complete, even if the requirements for the next if are true, it won't do anything.

Of course there may be something I didn't learn already. But I need to know this now to take it into account as I have ~5 months to finish the programming of the project. So is there something like running multiple programs (like different voids) at the same time? Another solution that I was thinking is making a time limit in each "if", so it can cycle through all of them until it finds one that meets the activation criteria, execute it and them keep moving.

Sorry for the long text, I'm trying to be as clear as possible. Also sorry if I'm missing anything essential and being a complete noob :stuck_out_tongue:
Greetings from Brazil

The if statement evaluates automatically. It doesn't wait wait for it to evaluate true or something before it continues. The arduino is fast enough to do all the things (within reason...) you want. Reads/writes take fractions of milliseconds (if they're still slow, there are ways to speed it up still). You generally don't need to worry about multitasking, just do it all in the loop.
There is, however, an arduino library called Protothreads that allows "simulated multitasking" (arduino only has one core, but Protothreads basically manages sharing clock cycles to different "processes").

Twski:
My question is, how can I make the Arduino put a 1 on port X1 if it receives order Y1 from the RaspPi or do the same if it detects that its below 10 degrees from a temp sensor; and in the same time, be able to receive order Y2 and activate port X2, order Y3 port Y3, etc. (X1, Y1, X2... are exemples)

Most Arduino boards run at 16 MHz, which means: 16 million instructions per second.

So in each millisecond you can run 16000 machine instructions.

And if 16000 machine instructions is enough for you to do "one thing at a time", then you can do a thousand things in every single second.

One call of "digitalRead" or "digitalWrite" is about 60 machine instructions.
One call if "analogRead" about 1900 machine instructions.

If you want to get the most of it, you have to avoid "busy waiting" in your program, which means that "delay()" is absolutely forbidden to use.

Instead you must use a programming logic that gets things done when its due to.

Slow timings must be done the way like slow blinking in the "BlinkWithoutDelay" example that ships with the Arduino IDE: Remember the time when the last action happened, then create the difference of "millis()-rememberedTime" and if the time has come ==> execute funktion and remember the next time.

If all the tasks are completely independent from each other, the loop() function may simply look like

void loop()
{
  task1();
  task2();
  task3();
  task4();
}

and you just write one task-function for every task to run.

Or if there are some tasks dependent on input or output of other tasks, then maybe the programming logic may look like

void loop()
{
  inputTask1();
  inputTask2();
  processingAllValues();
  outputTask3();
  outputTask4();
}

Or something like that. Each function call = at most one millisecond. If so, it all looks like executing at the same time. At least "at the same few milliseconds".

Catchwords "cooperative multitasking" and "round robin scheduling".
Of course a single controller cannot do several things "at the same time". But its possible to do a few microseconds this, a few microseconds that, and another few microseconds something completely different.

But afaik the Arduino can only process one thing at a time, if it's wating for the
if (Y1 == high) {digitalWrite (X1,HIGH)};

No. If someone asks you if it is raining, you don't hang around waiting for it to rain. It is either raining or it isn't.

As its name implies, the demo several things at a time is an illustration of multi-tasking. It is not difficult to achieve.

You may also be interested in planning and implementing a program

...R

Thank you all for the replies.
I kind of knew that the if statement don't wait for evaluation, but somehow it made sense for me to do so by the time I was wondering about it. I think I need more practice...

Nice analogy

@Robin2 thanks for the links, these will surely help me