I'm trying to find a way to optimize my code. For the moment I have a while loop in which several sensors are read out. But in the beginning of my code I first check what sensors that needs to be read out and I simply add an if function before every part of code. Is there a better way of doing this?
sensor1_actif=1
sensor2_actif=0
while True:
if(sensor1_actif==1):
x=sensor1read()
if(sensor2_actif==1):
y=sensor2read()
...