I have been making a miniature city, and now i want to add traffic lights on 4 intersections.
These traffic lights need to work all independent from each other (so every intersection has its own light control so not every intersection shows red at the same moment for example)
is there a way to do this? like creating 4 loops maybe ?
I'm pretty new so i ask first before i buy the components.
The basic principle is to have one big loop and to execute the functions in a sequential way
by using a technique that is called state-machine. Traffic-lights are a very typical application for state-machines
So as a rough picture the functionality of your code looks like this
where each function gets called again and again and all the steps of switching light from red to yellow, to green etc. is done by the program-logic of the state-machine
This means your code jumps in and out of the functions all the time
and something similar to if-conditions control which part of the code