im new to arduino and have a problem currently with my project on sun tracking. The problem is that every loop it resets my variable back to 1 or whatever i set it. I have 4 photodiodes working properly but using only 2 on one axis. Code example:
void loop(){
int stop1 = 1;
senzor read1 //this is just code example
senzor read2
senzor read3
senzor read4
if (senzor1>senzor2){stop1=senzor1 - senzor2}
if (senzor2>senzor1){stop1= senzor2 - senzor1}
if (stop<5){stop motors}
}
this is simple example code and the problem is that it doesn't stop, it keeps looking for light (successfuly) and doesn't stop. Sorry for bad English if any and thanky in advance.