Multiple lopps and global variables

Hi All - going to start programming some arduino stuff when I get my first board next week.

I’m just scoping out an initial project and wondered if it is possible to have multiple loops in a project with one loop adjusting a global variable that another loop can access etc… So can loops update and read global variables?

You only get one loop function. But you can use other constructs to create looping sections of code. And any piece of code can modify a global variable and any other piece of code can access it and see those changes.

Go find a C++ tutorial on line and get the basics. It will all become much clearer that way than trying to read other people’s (often poorly written) Arduino sketches.

When people ask for two loops, they often mean that they want to do several things at the same time.

aarg: When people ask for two loops, they often mean that they want to do several things at the same time.

Thanks for that very helpful. So the functions called within the main loop will be called continuously. I get it thanks. So a local variable in the main loop would be available for all the functions called from it?

Welcome

You might want to spend some time on this page and the links it offers. https://www.arduino.cc/en/Tutorial/Foundations

originnz: Thanks for that very helpful. So the functions called within the main loop will be called continuously. I get it thanks. So a local variable in the main loop would be available for all the functions called from it?

No, you have to declare such variables globally. Because loop() is a function.