How loop() function work

Hi everyone,

I'm not very familiar with the programmation of microcontrollers, so I have a question regarding the loop() function.

I try to do a program in python which send some informations to an arduino through serial port (such as char and int or float) and then, as a function of the received signal, the arduino put high or low some pins.

I don't have yet a functionnal code but I want to understand how can I do some actions only one time and only at a specific time. For instance :

1: I send some informations (3 int) from python to my arduino.
2: I want to process these 3 int with my arduino and create 3 array with the size of each int.
3: I send another informations through serial port (char) and I want to put these char in arrays created before.

The size of each array does not change but the char inside could be changed at any time. My first idea was to send one char, such as 'F' for first, and put a if condition on the loop() function to do the step 2 only one time. Is a good idea or there is some tricks more simple that I miss ?

Thank everyone for your help !

You can search for the ‘serial input basics’ thread on this forum to get some ideas for the Arduino side of things. If I remember correctly, the same author also wrote an article about using python on the pc; I think it’s available in the ‘interfacing with pc’ section on this forum.

These links may help

Python - Arduino demo

Serial Input Basics