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)