Logic Fuzzy Tracker Solar

I designed a fuzzy control in matlab and exported it to the Arduino IDE. The control has two inputs that the first is the difference of the values of the two light sensors and the other input is the difference between the current and the previous error. The output is the servo motor control.
The code is attached, but the servo motor values are not working. Can you help me. Would greatly appreciate it.

erro = analogRead(0) - analogRead(1);
dErro = erro - erroAnterior;
erroAnterior = erro;

g_fisInput[0] = erro;
g_fisInput[1] = dErro;
g_fisOutput[0] = 0;

fis_evaluate();
g_fisOutput[0] = map(g_fisOutput[0],-1023,1023,0,180);
analogWrite(9 , g_fisOutput[0]);
myservo.write(g_fisOutput[0]);

fiscontrole_.zip (13.9 KB)

Capturar.PNG

In view of the fact that the sun's position can be predicted to the nearest second of arc for the next X thousand years I don't understand the need for anything fuzzy. :slight_smile:

I would just write a program that implements this logic

read the two LDRs
if one is brighter than the other move a little bit towards the brighter one
repeat

...R