Carrinho 4wd com fuzzy

Boa Noite,

Estou realizando um trabalho de IA e a saida não está funcionando. Estou usando Arduino Mega 2560.

Segue programação:

#include "Ultrasonic.h"
#include "Fuzzy.h"
#include "FuzzyComposition.h"
#include "FuzzyInput.h"
#include "FuzzyIO.h"
#include "FuzzyOutput.h"
#include "FuzzyRule.h"
#include "FuzzyRuleAntecedent.h"
#include "FuzzyRuleConsequent.h"
#include "FuzzySet.h"

Fuzzy *fuzzy = new Fuzzy();

//VARIAVEIS MOTORES
int vel4 = 2; //Velocidade motor 4
int e14 = 3; //Entrada positivo do motor 4
int e24 = 4; //Entrada negativo do motor 4

int vel3 = 7; //Velocidade motor 3
int e13 = 5; //Entrada do terminal do motor 3
int e23 = 6; //Entrada do terminal do motor 3

int vel2 = 8; //Velocidade motor 2
int e12 = 9; //Entrada do terminal do motor 2
int e22 = 10; //Entrada do terminal do motor 2

int vel1 = 13; //Velocidade motor 1
int e11 = 11; //Entrada do terminal do motor 1
int e21 = 12; //Entrada do terminal do motor 1

//VARIAVEIS SENSOR

int echoPin1 = 23; //PINO DIGITAL HC-SR04 ECHO(RECEBE) - SENSOR FRENTE
int trigPin1 = 22; //PINO DIGITAL HC-SR04 TRIG(ENVIA) - SENSOR FRENTE

int echoPin2 = 53; //PINO DIGITAL HC-SR04 ECHO(RECEBE) - SENSOR ATRAS
int trigPin2 = 52; //PINO DIGITAL HC-SR04 TRIG(ENVIA) - SENSOR ATRAS

int echoPin3 = 25; //PINO DIGITAL HC-SR04 ECHO(RECEBE) - SENSOR ESQUERDO
int trigPin3 = 24; //PINO DIGITAL HC-SR04 TRIG(ENVIA) - SENSOR ESQUERDO

int echoPin4 = 27; //PINO DIGITAL HC-SR04 ECHO(RECEBE) - SENSOR DIREITO
int trigPin4 = 26; //PINO DIGITAL HC-SR04 TRIG(ENVIA) - SENSOR DIREITO


long duracao1;
long HR_dist1 = 0;

long duracao2;
long HR_dist2 = 0;

long duracao3;
long HR_dist3 = 0;

long duracao4;
long HR_dist4 = 0;

void setup()
{
  Serial.begin(9600);


  //Define os pinos como entrada e saida dos sensores
  pinMode(trigPin1, OUTPUT); //define o pino TRIG como saída
  pinMode(echoPin1, INPUT); //define o pino ECHO como entrada

  pinMode(trigPin2, OUTPUT); //define o pino TRIG como saída
  pinMode(echoPin2, INPUT); //define o pino ECHO como entrada

  pinMode(trigPin3, OUTPUT); //define o pino TRIG como saída
  pinMode(echoPin3, INPUT); //define o pino ECHO como entrada

  pinMode(trigPin4, OUTPUT); //define o pino TRIG como saída
  pinMode(echoPin4, INPUT); //define o pino ECHO como entrada


  //Define os pinos como saida dos motores
  pinMode(vel4, OUTPUT);
  pinMode(vel3, OUTPUT);
  pinMode(vel2, OUTPUT);
  pinMode(vel1, OUTPUT);

  pinMode(e14, OUTPUT);
  pinMode(e24, OUTPUT);

  pinMode(e13, OUTPUT);
  pinMode(e23, OUTPUT);

  pinMode(e12, OUTPUT);
  pinMode(e22, OUTPUT);

  pinMode(e11, OUTPUT);
  pinMode(e21, OUTPUT);

  // ENTRADA FUZZY
  FuzzyInput * distancia_esquerda = new FuzzyInput(1);

  FuzzySet * e_perto = new FuzzySet(0, 0, 10, 10);
  distancia_esquerda->addFuzzySet(e_perto);

  FuzzySet * e_medio = new FuzzySet(0, 10, 40, 50);
  distancia_esquerda->addFuzzySet(e_medio);

  FuzzySet * e_longe = new FuzzySet(50, 60, 100, 100);
  distancia_esquerda->addFuzzySet(e_longe);

  fuzzy->addFuzzyInput(distancia_esquerda);



  FuzzyInput * distancia_direita = new FuzzyInput(2);

  FuzzySet * d_perto = new FuzzySet(0, 0, 10, 10);
  distancia_direita->addFuzzySet(d_perto);

  FuzzySet * d_medio = new FuzzySet(0, 10, 40, 50);
  distancia_direita->addFuzzySet(d_medio);

  FuzzySet * d_longe = new FuzzySet(50, 60, 100, 100);
  distancia_direita->addFuzzySet(d_longe);

  fuzzy->addFuzzyInput(distancia_direita);


  FuzzyInput * distancia_frente = new FuzzyInput(3);

  FuzzySet * f_perto = new FuzzySet(0, 0, 10, 10);
  distancia_frente->addFuzzySet(f_perto);

  FuzzySet * f_medio = new FuzzySet(0, 10, 40, 50);
  distancia_frente->addFuzzySet(f_medio);

  FuzzySet * f_longe = new FuzzySet(50, 60, 100, 100);
  distancia_frente->addFuzzySet(f_longe);

  fuzzy->addFuzzyInput(distancia_frente);


  FuzzyInput * distancia_atras = new FuzzyInput(4);

  FuzzySet * a_perto = new FuzzySet(0, 0, 10, 10);
  distancia_atras->addFuzzySet(a_perto);

  FuzzySet * a_medio = new FuzzySet(0, 10, 40, 50);
  distancia_atras->addFuzzySet(a_medio);

  FuzzySet * a_longe = new FuzzySet(50, 60, 100, 100);
  distancia_atras->addFuzzySet(a_longe);

  fuzzy->addFuzzyInput(distancia_atras);


  //SAIDA FUZZY
  FuzzyOutput * direcao = new FuzzyOutput(1);

  FuzzySet * esquerda = new FuzzySet(0, 0, -90, -90);
  direcao->addFuzzySet(esquerda);

  FuzzySet * direita = new FuzzySet(0, 0, 90, 90);
  direcao->addFuzzySet(direita);

  FuzzySet * nada = new FuzzySet(0, 0, 0, 0);
  direcao->addFuzzySet(nada);

  fuzzy->addFuzzyOutput(direcao);



  FuzzyOutput * movimento = new FuzzyOutput(2);

  FuzzySet * frente = new FuzzySet(0, 0, 1, 100);
  movimento->addFuzzySet(frente);

  FuzzySet * re = new FuzzySet(-100, 0, 0, 100);
  movimento->addFuzzySet(re);

  FuzzySet * parado = new FuzzySet(0, 0, 0, 0);
  movimento->addFuzzySet(parado);

  fuzzy->addFuzzyOutput(movimento);



  //REGRAS FUZZY - SIMPLES
  FuzzyRuleAntecedent * e_perto_d_perto = new FuzzyRuleAntecedent();
  e_perto_d_perto->joinWithAND(e_perto, d_perto);

  FuzzyRuleAntecedent * e_perto_d_medio = new FuzzyRuleAntecedent();
  e_perto_d_medio->joinWithAND(e_perto, d_medio);

  FuzzyRuleAntecedent * e_perto_d_longe = new FuzzyRuleAntecedent();
  e_perto_d_longe->joinWithAND(e_perto, d_longe);

  FuzzyRuleAntecedent * e_medio_d_perto = new FuzzyRuleAntecedent();
  e_perto_d_perto->joinWithAND(e_medio, d_perto);

  FuzzyRuleAntecedent * e_medio_d_medio = new FuzzyRuleAntecedent();
  e_perto_d_medio->joinWithAND(e_medio, d_medio);

  FuzzyRuleAntecedent * e_medio_d_longe = new FuzzyRuleAntecedent();
  e_perto_d_longe->joinWithAND(e_medio, d_longe);

  FuzzyRuleAntecedent * e_longe_d_perto = new FuzzyRuleAntecedent();
  e_longe_d_perto->joinWithAND(e_medio, d_perto);

  FuzzyRuleAntecedent * e_longe_d_medio = new FuzzyRuleAntecedent();
  e_longe_d_medio->joinWithAND(e_medio, d_medio);

  FuzzyRuleAntecedent * e_longe_d_longe = new FuzzyRuleAntecedent();
  e_longe_d_longe->joinWithAND(e_medio, d_longe);


  FuzzyRuleAntecedent * f_perto_a_perto = new FuzzyRuleAntecedent();
  f_perto_a_perto->joinWithAND(f_perto, a_perto);

  FuzzyRuleAntecedent * f_perto_a_medio = new FuzzyRuleAntecedent();
  f_perto_a_medio->joinWithAND(f_perto, a_medio);

  FuzzyRuleAntecedent * f_perto_a_longe = new FuzzyRuleAntecedent();
  f_perto_a_longe->joinWithAND(f_perto, a_longe);

  FuzzyRuleAntecedent * f_medio_a_perto = new FuzzyRuleAntecedent();
  f_medio_a_perto->joinWithAND(f_perto, a_perto);

  FuzzyRuleAntecedent * f_medio_a_medio = new FuzzyRuleAntecedent();
  f_medio_a_medio->joinWithAND(f_perto, a_medio);

  FuzzyRuleAntecedent * f_medio_a_longe = new FuzzyRuleAntecedent();
  f_medio_a_longe->joinWithAND(f_perto, a_longe);

  FuzzyRuleAntecedent * f_longe_a_perto = new FuzzyRuleAntecedent();
  f_longe_a_perto->joinWithAND(f_perto, a_perto);

  FuzzyRuleAntecedent * f_longe_a_medio = new FuzzyRuleAntecedent();
  f_longe_a_medio->joinWithAND(f_perto, a_medio);

  FuzzyRuleAntecedent * f_longe_a_longe = new FuzzyRuleAntecedent();
  f_longe_a_longe->joinWithAND(f_perto, a_longe);


  //REGRAS FUZZY - COMPOSTAS

  //FRENTE PERTO - ATRAS PERTO
  FuzzyRuleAntecedent * e_perto_d_perto__f_perto_a_perto = new FuzzyRuleAntecedent();
  e_perto_d_perto__f_perto_a_perto->joinWithAND(e_perto_d_perto, f_perto_a_perto);
  FuzzyRuleConsequent * entao_nada_a = new FuzzyRuleConsequent();
  entao_nada_a->addOutput(parado);
  FuzzyRule * Regra_01 = new FuzzyRule(1, e_perto_d_perto__f_perto_a_perto, entao_nada_a);
  fuzzy->addFuzzyRule(Regra_01);


  FuzzyRuleAntecedent * e_perto_d_medio__f_perto_a_perto = new FuzzyRuleAntecedent();
  e_perto_d_medio__f_perto_a_perto->joinWithAND(e_perto_d_medio, f_perto_a_perto);
  FuzzyRuleConsequent * entao_nada_b = new FuzzyRuleConsequent();
  entao_nada_b->addOutput(parado);
  FuzzyRule * Regra_02 = new FuzzyRule(2, e_perto_d_medio__f_perto_a_perto, entao_nada_b);
  fuzzy->addFuzzyRule(Regra_02);


  FuzzyRuleAntecedent * e_perto_d_longe__f_perto_a_perto = new FuzzyRuleAntecedent();
  e_perto_d_longe__f_perto_a_perto->joinWithAND(e_perto_d_longe, f_perto_a_perto);
  FuzzyRuleConsequent * entao_nada_c = new FuzzyRuleConsequent();
  entao_nada_c->addOutput(parado);
  FuzzyRule * Regra_03 = new FuzzyRule(3, e_perto_d_longe__f_perto_a_perto, entao_nada_c);
  fuzzy->addFuzzyRule(Regra_03);



  FuzzyRuleAntecedent * e_medio_d_perto__f_perto_a_perto = new FuzzyRuleAntecedent();
  e_medio_d_perto__f_perto_a_perto->joinWithAND(e_medio_d_perto, f_perto_a_perto);
  FuzzyRuleConsequent * entao_nada_d = new FuzzyRuleConsequent();
  entao_nada_d->addOutput(parado);
  FuzzyRule * Regra_04 = new FuzzyRule(4, e_medio_d_perto__f_perto_a_perto, entao_nada_d);
  fuzzy->addFuzzyRule(Regra_04);


  FuzzyRuleAntecedent * e_medio_d_medio__f_perto_a_perto = new FuzzyRuleAntecedent();
  e_medio_d_medio__f_perto_a_perto->joinWithAND(e_medio_d_medio, f_perto_a_perto);
  FuzzyRuleConsequent * entao_nada_e = new FuzzyRuleConsequent();
  entao_nada_e->addOutput(parado);
  FuzzyRule * Regra_05 = new FuzzyRule(5, e_medio_d_medio__f_perto_a_perto, entao_nada_e);
  fuzzy->addFuzzyRule(Regra_05);


  FuzzyRuleAntecedent * e_medio_d_longe__f_perto_a_perto = new FuzzyRuleAntecedent();
  e_medio_d_longe__f_perto_a_perto->joinWithAND(e_medio_d_longe, f_perto_a_perto);
  FuzzyRuleConsequent * entao_nada_f = new FuzzyRuleConsequent();
  entao_nada_f->addOutput(parado);
  FuzzyRule * Regra_06 = new FuzzyRule(6, e_medio_d_longe__f_perto_a_perto, entao_nada_f);
  fuzzy->addFuzzyRule(Regra_06);



  FuzzyRuleAntecedent * e_longe_d_perto__f_perto_a_perto = new FuzzyRuleAntecedent();
  e_longe_d_perto__f_perto_a_perto->joinWithAND(e_longe_d_perto, f_perto_a_perto);
  FuzzyRuleConsequent * entao_nada_g = new FuzzyRuleConsequent();
  entao_nada_g->addOutput(parado);
  FuzzyRule * Regra_07 = new FuzzyRule(7, e_longe_d_perto__f_perto_a_perto, entao_nada_g);
  fuzzy->addFuzzyRule(Regra_07);


  FuzzyRuleAntecedent * e_longe_d_medio__f_perto_a_perto = new FuzzyRuleAntecedent();
  e_longe_d_medio__f_perto_a_perto->joinWithAND(e_longe_d_medio, f_perto_a_perto);
  FuzzyRuleConsequent * entao_nada_h = new FuzzyRuleConsequent();
  entao_nada_h->addOutput(parado);
  FuzzyRule * Regra_08 = new FuzzyRule(8, e_longe_d_medio__f_perto_a_perto, entao_nada_h);
  fuzzy->addFuzzyRule(Regra_08);


  FuzzyRuleAntecedent * e_longe_d_longe__f_perto_a_perto = new FuzzyRuleAntecedent();
  e_longe_d_longe__f_perto_a_perto->joinWithAND(e_longe_d_longe, f_perto_a_perto);
  FuzzyRuleConsequent * entao_nada_i = new FuzzyRuleConsequent();
  entao_nada_i->addOutput(parado);
  FuzzyRule * Regra_09 = new FuzzyRule(9, e_longe_d_longe__f_perto_a_perto, entao_nada_i);
  fuzzy->addFuzzyRule(Regra_09);



  //FRENTE MEDIO - ATRAS PERTO
  FuzzyRuleAntecedent * e_perto_d_perto__f_medio_a_perto = new FuzzyRuleAntecedent();
  e_perto_d_perto__f_medio_a_perto->joinWithAND(e_perto_d_perto, f_medio_a_perto);
  FuzzyRuleConsequent * entao_frente_a_a = new FuzzyRuleConsequent();
  entao_frente_a_a->addOutput(frente);
  FuzzyRule * Regra_10 = new FuzzyRule(10, e_perto_d_perto__f_perto_a_perto, entao_frente_a_a);
  fuzzy->addFuzzyRule(Regra_10);


  FuzzyRuleAntecedent * e_perto_d_medio__f_medio_a_perto = new FuzzyRuleAntecedent();
  e_perto_d_medio__f_medio_a_perto->joinWithAND(e_perto_d_medio, f_medio_a_perto);
  FuzzyRuleConsequent * entao_frente_a_b = new FuzzyRuleConsequent();
  entao_frente_a_b->addOutput(frente);
  entao_frente_a_b->addOutput(direita);
  FuzzyRule * Regra_11 = new FuzzyRule(11, e_perto_d_medio__f_perto_a_perto, entao_frente_a_b);
  fuzzy->addFuzzyRule(Regra_11);


  FuzzyRuleAntecedent * e_perto_d_longe__f_medio_a_perto = new FuzzyRuleAntecedent();
  e_perto_d_longe__f_medio_a_perto->joinWithAND(e_perto_d_longe, f_medio_a_perto);
  FuzzyRuleConsequent * entao_frente_a_c = new FuzzyRuleConsequent();
  entao_frente_a_c->addOutput(frente);
  entao_frente_a_c->addOutput(direita);
  FuzzyRule * Regra_12 = new FuzzyRule(12, e_perto_d_longe__f_perto_a_perto, entao_frente_a_c);
  fuzzy->addFuzzyRule(Regra_12);



  FuzzyRuleAntecedent * e_medio_d_perto__f_medio_a_perto = new FuzzyRuleAntecedent();
  e_medio_d_perto__f_medio_a_perto->joinWithAND(e_medio_d_perto, f_medio_a_perto);
  FuzzyRuleConsequent * entao_frente_a_d = new FuzzyRuleConsequent();
  entao_frente_a_d->addOutput(frente);
  entao_frente_a_d->addOutput(esquerda);
  FuzzyRule * Regra_13 = new FuzzyRule(13, e_medio_d_perto__f_perto_a_perto, entao_frente_a_d);
  fuzzy->addFuzzyRule(Regra_13);


  FuzzyRuleAntecedent * e_medio_d_medio__f_medio_a_perto = new FuzzyRuleAntecedent();
  e_medio_d_medio__f_medio_a_perto->joinWithAND(e_medio_d_medio, f_medio_a_perto);
  FuzzyRuleConsequent * entao_frente_a_e = new FuzzyRuleConsequent();
  entao_frente_a_e->addOutput(frente);
  FuzzyRule * Regra_14 = new FuzzyRule(14, e_medio_d_medio__f_perto_a_perto, entao_frente_a_e);
  fuzzy->addFuzzyRule(Regra_14);


  FuzzyRuleAntecedent * e_medio_d_longe__f_medio_a_perto = new FuzzyRuleAntecedent();
  e_medio_d_longe__f_medio_a_perto->joinWithAND(e_medio_d_longe, f_medio_a_perto);
  FuzzyRuleConsequent * entao_frente_a_f = new FuzzyRuleConsequent();
  entao_frente_a_f->addOutput(frente);
  FuzzyRule * Regra_15 = new FuzzyRule(15, e_medio_d_longe__f_perto_a_perto, entao_frente_a_f);
  fuzzy->addFuzzyRule(Regra_15);



  FuzzyRuleAntecedent * e_longe_d_perto__f_medio_a_perto = new FuzzyRuleAntecedent();
  e_longe_d_perto__f_medio_a_perto->joinWithAND(e_longe_d_perto, f_medio_a_perto);
  FuzzyRuleConsequent * entao_frente_a_g = new FuzzyRuleConsequent();
  entao_frente_a_g->addOutput(frente);
  entao_frente_a_g->addOutput(esquerda);
  FuzzyRule * Regra_16 = new FuzzyRule(16, e_longe_d_perto__f_perto_a_perto, entao_frente_a_g);
  fuzzy->addFuzzyRule(Regra_16);


  FuzzyRuleAntecedent * e_longe_d_medio__f_medio_a_perto = new FuzzyRuleAntecedent();
  e_longe_d_medio__f_medio_a_perto->joinWithAND(e_longe_d_medio, f_medio_a_perto);
  FuzzyRuleConsequent * entao_frente_a_h = new FuzzyRuleConsequent();
  entao_frente_a_h->addOutput(frente);
  FuzzyRule * Regra_17 = new FuzzyRule(17, e_longe_d_medio__f_perto_a_perto, entao_frente_a_h);
  fuzzy->addFuzzyRule(Regra_17);


  FuzzyRuleAntecedent * e_longe_d_longe__f_medio_a_perto = new FuzzyRuleAntecedent();
  e_longe_d_longe__f_medio_a_perto->joinWithAND(e_longe_d_longe, f_medio_a_perto);
  FuzzyRuleConsequent * entao_frente_a_i = new FuzzyRuleConsequent();
  entao_frente_a_i->addOutput(frente);
  FuzzyRule * Regra_18 = new FuzzyRule(18, e_longe_d_longe__f_perto_a_perto, entao_frente_a_i);
  fuzzy->addFuzzyRule(Regra_18);



  //FRENTE LONGE - ATRAS PERTO
  FuzzyRuleAntecedent * e_perto_d_perto__f_longe_a_perto = new FuzzyRuleAntecedent();
  e_perto_d_perto__f_longe_a_perto->joinWithAND(e_perto_d_perto, f_longe_a_perto);
  FuzzyRuleConsequent * entao_frente_b_a = new FuzzyRuleConsequent();
  entao_frente_b_a->addOutput(frente);
  FuzzyRule * Regra_19 = new FuzzyRule(19, e_perto_d_perto__f_longe_a_perto, entao_frente_b_a);
  fuzzy->addFuzzyRule(Regra_19);


  FuzzyRuleAntecedent * e_perto_d_medio__f_longe_a_perto = new FuzzyRuleAntecedent();
  e_perto_d_medio__f_longe_a_perto->joinWithAND(e_perto_d_medio, f_longe_a_perto);
  FuzzyRuleConsequent * entao_frente_b_b = new FuzzyRuleConsequent();
  entao_frente_b_b->addOutput(frente);
  entao_frente_b_b->addOutput(direita);
  FuzzyRule * Regra_20 = new FuzzyRule(20, e_perto_d_medio__f_longe_a_perto, entao_frente_b_b);
  fuzzy->addFuzzyRule(Regra_20);


  FuzzyRuleAntecedent * e_perto_d_longe__f_longe_a_perto = new FuzzyRuleAntecedent();
  e_perto_d_longe__f_longe_a_perto->joinWithAND(e_perto_d_longe, f_longe_a_perto);
  FuzzyRuleConsequent * entao_frente_b_c = new FuzzyRuleConsequent();
  entao_frente_b_c->addOutput(frente);
  entao_frente_b_c->addOutput(direita);
  FuzzyRule * Regra_21 = new FuzzyRule(21, e_perto_d_longe__f_longe_a_perto, entao_frente_b_c);
  fuzzy->addFuzzyRule(Regra_21);



  FuzzyRuleAntecedent * e_medio_d_perto__f_longe_a_perto = new FuzzyRuleAntecedent();
  e_medio_d_perto__f_longe_a_perto->joinWithAND(e_medio_d_perto, f_longe_a_perto);
  FuzzyRuleConsequent * entao_frente_b_d = new FuzzyRuleConsequent();
  entao_frente_b_d->addOutput(frente);
  entao_frente_b_d->addOutput(esquerda);
  FuzzyRule * Regra_22 = new FuzzyRule(22, e_medio_d_perto__f_longe_a_perto, entao_frente_b_d);
  fuzzy->addFuzzyRule(Regra_22);


  FuzzyRuleAntecedent * e_medio_d_medio__f_longe_a_perto = new FuzzyRuleAntecedent();
  e_medio_d_medio__f_longe_a_perto->joinWithAND(e_medio_d_medio, f_longe_a_perto);
  FuzzyRuleConsequent * entao_frente_b_e = new FuzzyRuleConsequent();
  entao_frente_b_e->addOutput(frente);
  FuzzyRule * Regra_23 = new FuzzyRule(23, e_medio_d_medio__f_longe_a_perto, entao_frente_b_e);
  fuzzy->addFuzzyRule(Regra_23);


  FuzzyRuleAntecedent * e_medio_d_longe__f_longe_a_perto = new FuzzyRuleAntecedent();
  e_medio_d_longe__f_longe_a_perto->joinWithAND(e_medio_d_longe, f_longe_a_perto);
  FuzzyRuleConsequent * entao_frente_b_f = new FuzzyRuleConsequent();
  entao_frente_b_f->addOutput(frente);
  FuzzyRule * Regra_24 = new FuzzyRule(24, e_medio_d_longe__f_longe_a_perto, entao_frente_b_f);
  fuzzy->addFuzzyRule(Regra_24);



  FuzzyRuleAntecedent * e_longe_d_perto__f_longe_a_perto = new FuzzyRuleAntecedent();
  e_longe_d_perto__f_longe_a_perto->joinWithAND(e_longe_d_perto, f_longe_a_perto);
  FuzzyRuleConsequent * entao_frente_b_g = new FuzzyRuleConsequent();
  entao_frente_b_g->addOutput(frente);
  entao_frente_b_g->addOutput(esquerda);
  FuzzyRule * Regra_25 = new FuzzyRule(25, e_longe_d_perto__f_longe_a_perto, entao_frente_b_g);
  fuzzy->addFuzzyRule(Regra_25);


  FuzzyRuleAntecedent * e_longe_d_medio__f_longe_a_perto = new FuzzyRuleAntecedent();
  e_longe_d_medio__f_longe_a_perto->joinWithAND(e_longe_d_medio, f_longe_a_perto);
  FuzzyRuleConsequent * entao_frente_b_h = new FuzzyRuleConsequent();
  entao_frente_b_h->addOutput(frente);
  FuzzyRule * Regra_26 = new FuzzyRule(26, e_longe_d_medio__f_longe_a_perto, entao_frente_b_h);
  fuzzy->addFuzzyRule(Regra_26);


  FuzzyRuleAntecedent * e_longe_d_longe__f_longe_a_perto = new FuzzyRuleAntecedent();
  e_longe_d_longe__f_longe_a_perto->joinWithAND(e_longe_d_longe, f_longe_a_perto);
  FuzzyRuleConsequent * entao_frente_b_i = new FuzzyRuleConsequent();
  entao_frente_b_i->addOutput(frente);
  FuzzyRule * Regra_27 = new FuzzyRule(27, e_longe_d_longe__f_longe_a_perto, entao_frente_b_i);
  fuzzy->addFuzzyRule(Regra_27);



  //FRENTE PERTO - ATRAS MEDIO
  FuzzyRuleAntecedent * e_perto_d_perto__f_perto_a_medio = new FuzzyRuleAntecedent();
  e_perto_d_perto__f_perto_a_perto->joinWithAND(e_perto_d_perto, f_perto_a_medio);
  FuzzyRuleConsequent * entao_frente_c_a = new FuzzyRuleConsequent();
  entao_frente_c_a->addOutput(frente);
  FuzzyRule * Regra_28 = new FuzzyRule(28, e_perto_d_perto__f_perto_a_medio, entao_frente_c_a);
  fuzzy->addFuzzyRule(Regra_28);


  FuzzyRuleAntecedent * e_perto_d_medio__f_perto_a_medio = new FuzzyRuleAntecedent();
  e_perto_d_medio__f_perto_a_perto->joinWithAND(e_perto_d_medio, f_perto_a_perto);
  FuzzyRuleConsequent * entao_frente_c_b = new FuzzyRuleConsequent();
  entao_frente_c_b->addOutput(frente);
  entao_frente_c_b->addOutput(direita);
  FuzzyRule * Regra_29 = new FuzzyRule(29, e_perto_d_medio__f_perto_a_perto, entao_frente_c_b);
  fuzzy->addFuzzyRule(Regra_29);


  FuzzyRuleAntecedent * e_perto_d_longe__f_perto_a_medio = new FuzzyRuleAntecedent();
  e_perto_d_longe__f_perto_a_perto->joinWithAND(e_perto_d_longe, f_perto_a_perto);
  FuzzyRuleConsequent * entao_frente_c_c = new FuzzyRuleConsequent();
  entao_frente_c_c->addOutput(frente);
  entao_frente_c_c->addOutput(direita);
  FuzzyRule * Regra_30 = new FuzzyRule(30, e_perto_d_longe__f_perto_a_perto, entao_frente_c_c);
  fuzzy->addFuzzyRule(Regra_30);



  FuzzyRuleAntecedent * e_medio_d_perto__f_perto_a_medio = new FuzzyRuleAntecedent();
  e_medio_d_perto__f_perto_a_perto->joinWithAND(e_medio_d_perto, f_perto_a_perto);
  FuzzyRuleConsequent * entao_frente_c_d = new FuzzyRuleConsequent();
  entao_frente_c_d->addOutput(frente);
  entao_frente_c_d->addOutput(esquerda);
  FuzzyRule * Regra_31 = new FuzzyRule(31, e_medio_d_perto__f_perto_a_perto, entao_frente_c_d);
  fuzzy->addFuzzyRule(Regra_31);


  FuzzyRuleAntecedent * e_medio_d_medio__f_perto_a_medio = new FuzzyRuleAntecedent();
  e_medio_d_medio__f_perto_a_perto->joinWithAND(e_medio_d_medio, f_perto_a_perto);
  FuzzyRuleConsequent * entao_frente_c_e = new FuzzyRuleConsequent();
  entao_frente_c_e->addOutput(frente);
  FuzzyRule * Regra_32 = new FuzzyRule(32, e_medio_d_medio__f_perto_a_perto, entao_frente_c_e);
  fuzzy->addFuzzyRule(Regra_32);


  FuzzyRuleAntecedent * e_medio_d_longe__f_perto_a_medio = new FuzzyRuleAntecedent();
  e_medio_d_longe__f_perto_a_perto->joinWithAND(e_medio_d_longe, f_perto_a_perto);
  FuzzyRuleConsequent * entao_frente_c_f = new FuzzyRuleConsequent();
  entao_frente_c_f->addOutput(frente);
  FuzzyRule * Regra_33 = new FuzzyRule(33, e_medio_d_longe__f_perto_a_perto, entao_frente_c_f);
  fuzzy->addFuzzyRule(Regra_33);



  FuzzyRuleAntecedent * e_longe_d_perto__f_perto_a_medio = new FuzzyRuleAntecedent();
  e_longe_d_perto__f_perto_a_perto->joinWithAND(e_longe_d_perto, f_perto_a_perto);
  FuzzyRuleConsequent * entao_frente_c_g = new FuzzyRuleConsequent();
  entao_frente_c_g->addOutput(frente);
  entao_frente_c_g->addOutput(esquerda);
  FuzzyRule * Regra_34 = new FuzzyRule(34, e_longe_d_perto__f_perto_a_perto, entao_frente_c_g);
  fuzzy->addFuzzyRule(Regra_34);


  FuzzyRuleAntecedent * e_longe_d_medio__f_perto_a_medio = new FuzzyRuleAntecedent();
  e_longe_d_medio__f_perto_a_perto->joinWithAND(e_longe_d_medio, f_perto_a_perto);
  FuzzyRuleConsequent * entao_frente_c_h = new FuzzyRuleConsequent();
  entao_frente_c_h->addOutput(frente);
  FuzzyRule * Regra_35 = new FuzzyRule(35, e_longe_d_medio__f_perto_a_perto, entao_frente_c_h);
  fuzzy->addFuzzyRule(Regra_35);


  FuzzyRuleAntecedent * e_longe_d_longe__f_perto_a_medio = new FuzzyRuleAntecedent();
  e_longe_d_longe__f_perto_a_perto->joinWithAND(e_longe_d_longe, f_perto_a_perto);
  FuzzyRuleConsequent * entao_frente_c_i = new FuzzyRuleConsequent();
  entao_frente_c_i->addOutput(frente);
  FuzzyRule * Regra_36 = new FuzzyRule(36, e_longe_d_longe__f_perto_a_perto, entao_frente_c_i);
  fuzzy->addFuzzyRule(Regra_36);



  //FRENTE MEDIO - ATRAS MEDIO
  FuzzyRuleAntecedent * e_perto_d_perto__f_medio_a_medio = new FuzzyRuleAntecedent();
  e_perto_d_perto__f_perto_a_perto->joinWithAND(e_perto_d_perto, f_perto_a_perto);
  FuzzyRuleConsequent * entao_frente_d_a = new FuzzyRuleConsequent();
  entao_frente_d_a->addOutput(frente);
  FuzzyRule * Regra_37 = new FuzzyRule(37, e_perto_d_perto__f_perto_a_perto, entao_frente_d_a);
  fuzzy->addFuzzyRule(Regra_37);


  FuzzyRuleAntecedent * e_perto_d_medio__f_medio_a_medio = new FuzzyRuleAntecedent();
  e_perto_d_medio__f_perto_a_perto->joinWithAND(e_perto_d_medio, f_perto_a_perto);
  FuzzyRuleConsequent * entao_frente_d_b = new FuzzyRuleConsequent();
  entao_frente_d_b->addOutput(frente);
  entao_frente_d_b->addOutput(direita);
  FuzzyRule * Regra_38 = new FuzzyRule(38, e_perto_d_medio__f_perto_a_perto, entao_frente_d_b);
  fuzzy->addFuzzyRule(Regra_38);


  FuzzyRuleAntecedent * e_perto_d_longe__f_medio_a_medio = new FuzzyRuleAntecedent();
  e_perto_d_longe__f_perto_a_perto->joinWithAND(e_perto_d_longe, f_perto_a_perto);
  FuzzyRuleConsequent * entao_frente_d_c = new FuzzyRuleConsequent();
  entao_frente_d_c->addOutput(frente);
  entao_frente_d_c->addOutput(direita);
  FuzzyRule * Regra_39 = new FuzzyRule(39, e_perto_d_longe__f_perto_a_perto, entao_frente_d_c);
  fuzzy->addFuzzyRule(Regra_39);



  FuzzyRuleAntecedent * e_medio_d_perto__f_medio_a_medio = new FuzzyRuleAntecedent();
  e_medio_d_perto__f_perto_a_perto->joinWithAND(e_medio_d_perto, f_perto_a_perto);
  FuzzyRuleConsequent * entao_frente_d_d = new FuzzyRuleConsequent();
  entao_frente_d_d->addOutput(frente);
  entao_frente_d_d->addOutput(esquerda);
  FuzzyRule * Regra_40 = new FuzzyRule(40, e_medio_d_perto__f_perto_a_perto, entao_frente_d_d);
  fuzzy->addFuzzyRule(Regra_40);


  FuzzyRuleAntecedent * e_medio_d_medio__f_medio_a_medio = new FuzzyRuleAntecedent();
  e_medio_d_medio__f_perto_a_perto->joinWithAND(e_medio_d_medio, f_perto_a_perto);
  FuzzyRuleConsequent * entao_frente_d_e = new FuzzyRuleConsequent();
  entao_frente_d_e->addOutput(frente);
  FuzzyRule * Regra_41 = new FuzzyRule(41, e_medio_d_medio__f_perto_a_perto, entao_frente_d_e);
  fuzzy->addFuzzyRule(Regra_41);


  FuzzyRuleAntecedent * e_medio_d_longe__f_medio_a_medio = new FuzzyRuleAntecedent();
  e_medio_d_longe__f_perto_a_perto->joinWithAND(e_medio_d_longe, f_perto_a_perto);
  FuzzyRuleConsequent * entao_frente_d_f = new FuzzyRuleConsequent();
  entao_frente_d_f->addOutput(frente);
  FuzzyRule * Regra_42 = new FuzzyRule(42, e_medio_d_longe__f_perto_a_perto, entao_frente_d_f);
  fuzzy->addFuzzyRule(Regra_42);



  FuzzyRuleAntecedent * e_longe_d_perto__f_medio_a_medio = new FuzzyRuleAntecedent();
  e_longe_d_perto__f_perto_a_perto->joinWithAND(e_longe_d_perto, f_perto_a_perto);
  FuzzyRuleConsequent * entao_frente_d_g = new FuzzyRuleConsequent();
  entao_frente_d_g->addOutput(frente);
  entao_frente_d_g->addOutput(esquerda);
  FuzzyRule * Regra_43 = new FuzzyRule(43, e_longe_d_perto__f_perto_a_perto, entao_frente_d_g);
  fuzzy->addFuzzyRule(Regra_43);


  FuzzyRuleAntecedent * e_longe_d_medio__f_medio_a_medio = new FuzzyRuleAntecedent();
  e_longe_d_medio__f_perto_a_perto->joinWithAND(e_longe_d_medio, f_perto_a_perto);
  FuzzyRuleConsequent * entao_frente_d_h = new FuzzyRuleConsequent();
  entao_frente_d_h->addOutput(frente);
  FuzzyRule * Regra_44 = new FuzzyRule(44, e_longe_d_medio__f_perto_a_perto, entao_frente_d_h);
  fuzzy->addFuzzyRule(Regra_44);


  FuzzyRuleAntecedent * e_longe_d_longe__f_medio_a_medio = new FuzzyRuleAntecedent();
  e_longe_d_longe__f_perto_a_perto->joinWithAND(e_longe_d_longe, f_perto_a_perto);
  FuzzyRuleConsequent * entao_frente_d_i = new FuzzyRuleConsequent();
  entao_frente_d_i->addOutput(frente);
  FuzzyRule * Regra_45 = new FuzzyRule(45, e_longe_d_longe__f_perto_a_perto, entao_frente_d_i);
  fuzzy->addFuzzyRule(Regra_45);



  //FRENTE LONGE - ATRAS MEDIO
  FuzzyRuleAntecedent * e_perto_d_perto__f_longe_a_medio = new FuzzyRuleAntecedent();
  e_perto_d_perto__f_perto_a_perto->joinWithAND(e_perto_d_perto, f_perto_a_perto);
  FuzzyRuleConsequent * entao_frente_e_a = new FuzzyRuleConsequent();
  entao_frente_e_a->addOutput(frente);
  FuzzyRule * Regra_46 = new FuzzyRule(46, e_perto_d_perto__f_perto_a_perto, entao_frente_e_a);
  fuzzy->addFuzzyRule(Regra_46);


  FuzzyRuleAntecedent * e_perto_d_medio__f_longe_a_medio = new FuzzyRuleAntecedent();
  e_perto_d_medio__f_perto_a_perto->joinWithAND(e_perto_d_medio, f_perto_a_perto);
  FuzzyRuleConsequent * entao_frente_e_b = new FuzzyRuleConsequent();
  entao_frente_e_b->addOutput(frente);
  entao_frente_e_b->addOutput(direita);
  FuzzyRule * Regra_47 = new FuzzyRule(47, e_perto_d_medio__f_perto_a_perto, entao_frente_e_b);
  fuzzy->addFuzzyRule(Regra_47);


  FuzzyRuleAntecedent * e_perto_d_longe__f_longe_a_medio = new FuzzyRuleAntecedent();
  e_perto_d_longe__f_perto_a_perto->joinWithAND(e_perto_d_longe, f_perto_a_perto);
  FuzzyRuleConsequent * entao_frente_e_c = new FuzzyRuleConsequent();
  entao_frente_e_c->addOutput(frente);
  entao_frente_e_c->addOutput(direita);
  FuzzyRule * Regra_48 = new FuzzyRule(48, e_perto_d_longe__f_perto_a_perto, entao_frente_e_c);
  fuzzy->addFuzzyRule(Regra_48);



  FuzzyRuleAntecedent * e_medio_d_perto__f_longe_a_medio = new FuzzyRuleAntecedent();
  e_medio_d_perto__f_perto_a_perto->joinWithAND(e_medio_d_perto, f_perto_a_perto);
  FuzzyRuleConsequent * entao_frente_e_d = new FuzzyRuleConsequent();
  entao_frente_e_d->addOutput(frente);
  entao_frente_e_d->addOutput(esquerda);
  FuzzyRule * Regra_49 = new FuzzyRule(49, e_medio_d_perto__f_perto_a_perto, entao_frente_e_d);
  fuzzy->addFuzzyRule(Regra_49);


  FuzzyRuleAntecedent * e_medio_d_medio__f_longe_a_medio = new FuzzyRuleAntecedent();
  e_medio_d_medio__f_perto_a_perto->joinWithAND(e_medio_d_medio, f_perto_a_perto);
  FuzzyRuleConsequent * entao_frente_e_e = new FuzzyRuleConsequent();
  entao_frente_e_e->addOutput(frente);
  FuzzyRule * Regra_50 = new FuzzyRule(50, e_medio_d_medio__f_perto_a_perto, entao_frente_e_e);
  fuzzy->addFuzzyRule(Regra_50);


  FuzzyRuleAntecedent * e_medio_d_longe__f_longe_a_medio = new FuzzyRuleAntecedent();
  e_medio_d_longe__f_perto_a_perto->joinWithAND(e_medio_d_longe, f_perto_a_perto);
  FuzzyRuleConsequent * entao_frente_e_f = new FuzzyRuleConsequent();
  entao_frente_e_f->addOutput(frente);
  FuzzyRule * Regra_51 = new FuzzyRule(51, e_medio_d_longe__f_perto_a_perto, entao_frente_e_f);
  fuzzy->addFuzzyRule(Regra_51);



  FuzzyRuleAntecedent * e_longe_d_perto__f_longe_a_medio = new FuzzyRuleAntecedent();
  e_longe_d_perto__f_perto_a_perto->joinWithAND(e_longe_d_perto, f_perto_a_perto);
  FuzzyRuleConsequent * entao_frente_e_g = new FuzzyRuleConsequent();
  entao_frente_e_g->addOutput(frente);
  entao_frente_e_g->addOutput(esquerda);
  FuzzyRule * Regra_52 = new FuzzyRule(52, e_longe_d_perto__f_perto_a_perto, entao_frente_e_g);
  fuzzy->addFuzzyRule(Regra_52);


  FuzzyRuleAntecedent * e_longe_d_medio__f_longe_a_medio = new FuzzyRuleAntecedent();
  e_longe_d_medio__f_perto_a_perto->joinWithAND(e_longe_d_medio, f_perto_a_perto);
  FuzzyRuleConsequent * entao_frente_e_h = new FuzzyRuleConsequent();
  entao_frente_e_h->addOutput(frente);
  FuzzyRule * Regra_53 = new FuzzyRule(53, e_longe_d_medio__f_perto_a_perto, entao_frente_e_h);
  fuzzy->addFuzzyRule(Regra_53);


  FuzzyRuleAntecedent * e_longe_d_longe__f_longe_a_medio = new FuzzyRuleAntecedent();
  e_longe_d_longe__f_perto_a_perto->joinWithAND(e_longe_d_longe, f_perto_a_perto);
  FuzzyRuleConsequent * entao_frente_e_i = new FuzzyRuleConsequent();
  entao_frente_e_i->addOutput(frente);
  FuzzyRule * Regra_54 = new FuzzyRule(54, e_longe_d_longe__f_perto_a_perto, entao_frente_e_i);
  fuzzy->addFuzzyRule(Regra_54);



  //FRENTE PERTO - ATRAS LONGE
  FuzzyRuleAntecedent * e_perto_d_perto__f_perto_a_longe = new FuzzyRuleAntecedent();
  e_perto_d_perto__f_perto_a_perto->joinWithAND(e_perto_d_perto, f_perto_a_perto);
  FuzzyRuleConsequent * entao_re_a = new FuzzyRuleConsequent();
  entao_re_a->addOutput(re);
  FuzzyRule * Regra_55 = new FuzzyRule(55, e_perto_d_perto__f_perto_a_perto, entao_re_a);
  fuzzy->addFuzzyRule(Regra_55);


  FuzzyRuleAntecedent * e_perto_d_medio__f_perto_a_longe = new FuzzyRuleAntecedent();
  e_perto_d_medio__f_perto_a_perto->joinWithAND(e_perto_d_medio, f_perto_a_perto);
  FuzzyRuleConsequent * entao_re_b = new FuzzyRuleConsequent();
  entao_re_b->addOutput(re);
  FuzzyRule * Regra_56 = new FuzzyRule(56, e_perto_d_medio__f_perto_a_perto, entao_re_b);
  fuzzy->addFuzzyRule(Regra_56);


  FuzzyRuleAntecedent * e_perto_d_longe__f_perto_a_longe = new FuzzyRuleAntecedent();
  e_perto_d_longe__f_perto_a_perto->joinWithAND(e_perto_d_longe, f_perto_a_perto);
  FuzzyRuleConsequent * entao_re_c = new FuzzyRuleConsequent();
  entao_re_c->addOutput(re);
  FuzzyRule * Regra_57 = new FuzzyRule(57, e_perto_d_longe__f_perto_a_perto, entao_re_c);
  fuzzy->addFuzzyRule(Regra_57);



  FuzzyRuleAntecedent * e_medio_d_perto__f_perto_a_longe = new FuzzyRuleAntecedent();
  e_medio_d_perto__f_perto_a_perto->joinWithAND(e_medio_d_perto, f_perto_a_perto);
  FuzzyRuleConsequent * entao_re_d = new FuzzyRuleConsequent();
  entao_re_d->addOutput(re);
  FuzzyRule * Regra_58 = new FuzzyRule(58, e_medio_d_perto__f_perto_a_perto, entao_re_d);
  fuzzy->addFuzzyRule(Regra_58);


  FuzzyRuleAntecedent * e_medio_d_medio__f_perto_a_longe = new FuzzyRuleAntecedent();
  e_medio_d_medio__f_perto_a_perto->joinWithAND(e_medio_d_medio, f_perto_a_perto);
  FuzzyRuleConsequent * entao_re_e = new FuzzyRuleConsequent();
  entao_re_e->addOutput(re);
  FuzzyRule * Regra_59 = new FuzzyRule(59, e_medio_d_medio__f_perto_a_perto, entao_re_e);
  fuzzy->addFuzzyRule(Regra_59);


  FuzzyRuleAntecedent * e_medio_d_longe__f_perto_a_longe = new FuzzyRuleAntecedent();
  e_medio_d_longe__f_perto_a_perto->joinWithAND(e_medio_d_longe, f_perto_a_perto);
  FuzzyRuleConsequent * entao_re_f = new FuzzyRuleConsequent();
  entao_re_f->addOutput(re);
  FuzzyRule * Regra_60 = new FuzzyRule(60, e_medio_d_longe__f_perto_a_perto, entao_re_f);
  fuzzy->addFuzzyRule(Regra_60);



  FuzzyRuleAntecedent * e_longe_d_perto__f_perto_a_longe = new FuzzyRuleAntecedent();
  e_longe_d_perto__f_perto_a_perto->joinWithAND(e_longe_d_perto, f_perto_a_perto);
  FuzzyRuleConsequent * entao_re_g = new FuzzyRuleConsequent();
  entao_re_g->addOutput(re);
  FuzzyRule * Regra_61 = new FuzzyRule(61, e_longe_d_perto__f_perto_a_perto, entao_re_g);
  fuzzy->addFuzzyRule(Regra_61);


  FuzzyRuleAntecedent * e_longe_d_medio__f_perto_a_longe = new FuzzyRuleAntecedent();
  e_longe_d_medio__f_perto_a_perto->joinWithAND(e_longe_d_medio, f_perto_a_perto);
  FuzzyRuleConsequent * entao_re_h = new FuzzyRuleConsequent();
  entao_re_h->addOutput(re);
  FuzzyRule * Regra_62 = new FuzzyRule(62, e_longe_d_medio__f_perto_a_perto, entao_re_h);
  fuzzy->addFuzzyRule(Regra_62);


  FuzzyRuleAntecedent * e_longe_d_longe__f_perto_a_longe = new FuzzyRuleAntecedent();
  e_longe_d_longe__f_perto_a_perto->joinWithAND(e_longe_d_longe, f_perto_a_perto);
  FuzzyRuleConsequent * entao_re_i = new FuzzyRuleConsequent();
  entao_re_i->addOutput(frente);
  FuzzyRule * Regra_63 = new FuzzyRule(63, e_longe_d_longe__f_perto_a_perto, entao_re_i);
  fuzzy->addFuzzyRule(Regra_63);



  //FRENTE MEDIO - ATRAS LONGE
  FuzzyRuleAntecedent * e_perto_d_perto__f_medio_a_longe = new FuzzyRuleAntecedent();
  e_perto_d_perto__f_perto_a_perto->joinWithAND(e_perto_d_perto, f_perto_a_perto);
  FuzzyRuleConsequent * entao_frente_f_a = new FuzzyRuleConsequent();
  entao_frente_f_a->addOutput(frente);
  FuzzyRule * Regra_64 = new FuzzyRule(64, e_perto_d_perto__f_perto_a_perto, entao_frente_f_a);
  fuzzy->addFuzzyRule(Regra_64);


  FuzzyRuleAntecedent * e_perto_d_medio__f_medio_a_longe = new FuzzyRuleAntecedent();
  e_perto_d_medio__f_perto_a_perto->joinWithAND(e_perto_d_medio, f_perto_a_perto);
  FuzzyRuleConsequent * entao_frente_f_b = new FuzzyRuleConsequent();
  entao_frente_f_b->addOutput(frente);
  entao_frente_f_b->addOutput(direita);
  FuzzyRule * Regra_65 = new FuzzyRule(65, e_perto_d_medio__f_perto_a_perto, entao_frente_f_b);
  fuzzy->addFuzzyRule(Regra_65);


  FuzzyRuleAntecedent * e_perto_d_longe__f_medio_a_longe = new FuzzyRuleAntecedent();
  e_perto_d_longe__f_perto_a_perto->joinWithAND(e_perto_d_longe, f_perto_a_perto);
  FuzzyRuleConsequent * entao_frente_f_c = new FuzzyRuleConsequent();
  entao_frente_f_c->addOutput(frente);
  entao_frente_f_c->addOutput(direita);
  FuzzyRule * Regra_66 = new FuzzyRule(66, e_perto_d_longe__f_perto_a_perto, entao_frente_f_c);
  fuzzy->addFuzzyRule(Regra_66);



  FuzzyRuleAntecedent * e_medio_d_perto__f_medio_a_longe = new FuzzyRuleAntecedent();
  e_medio_d_perto__f_perto_a_perto->joinWithAND(e_medio_d_perto, f_perto_a_perto);
  FuzzyRuleConsequent * entao_frente_f_d = new FuzzyRuleConsequent();
  entao_frente_f_d->addOutput(frente);
  entao_frente_f_d->addOutput(esquerda);
  FuzzyRule * Regra_67 = new FuzzyRule(67, e_medio_d_perto__f_perto_a_perto, entao_frente_f_d);
  fuzzy->addFuzzyRule(Regra_67);


  FuzzyRuleAntecedent * e_medio_d_medio__f_medio_a_longe = new FuzzyRuleAntecedent();
  e_medio_d_medio__f_perto_a_perto->joinWithAND(e_medio_d_medio, f_perto_a_perto);
  FuzzyRuleConsequent * entao_frente_f_e = new FuzzyRuleConsequent();
  entao_frente_f_e->addOutput(frente);
  FuzzyRule * Regra_68 = new FuzzyRule(68, e_medio_d_medio__f_perto_a_perto, entao_frente_f_e);
  fuzzy->addFuzzyRule(Regra_68);


  FuzzyRuleAntecedent * e_medio_d_longe__f_medio_a_longe = new FuzzyRuleAntecedent();
  e_medio_d_longe__f_perto_a_perto->joinWithAND(e_medio_d_longe, f_perto_a_perto);
  FuzzyRuleConsequent * entao_frente_f_f = new FuzzyRuleConsequent();
  entao_frente_f_f->addOutput(frente);
  FuzzyRule * Regra_69 = new FuzzyRule(69, e_medio_d_longe__f_perto_a_perto, entao_frente_f_f);
  fuzzy->addFuzzyRule(Regra_69);



  FuzzyRuleAntecedent * e_longe_d_perto__f_medio_a_longe = new FuzzyRuleAntecedent();
  e_longe_d_perto__f_perto_a_perto->joinWithAND(e_longe_d_perto, f_perto_a_perto);
  FuzzyRuleConsequent * entao_frente_f_g = new FuzzyRuleConsequent();
  entao_frente_f_g->addOutput(frente);
  entao_frente_f_g->addOutput(esquerda);
  FuzzyRule * Regra_70 = new FuzzyRule(70, e_longe_d_perto__f_perto_a_perto, entao_frente_f_g);
  fuzzy->addFuzzyRule(Regra_70);


  FuzzyRuleAntecedent * e_longe_d_medio__f_medio_a_longe = new FuzzyRuleAntecedent();
  e_longe_d_medio__f_perto_a_perto->joinWithAND(e_longe_d_medio, f_perto_a_perto);
  FuzzyRuleConsequent * entao_frente_f_h = new FuzzyRuleConsequent();
  entao_frente_f_h->addOutput(frente);
  FuzzyRule * Regra_71 = new FuzzyRule(71, e_longe_d_medio__f_perto_a_perto, entao_frente_f_h);
  fuzzy->addFuzzyRule(Regra_71);


  FuzzyRuleAntecedent * e_longe_d_longe__f_medio_a_longe = new FuzzyRuleAntecedent();
  e_longe_d_longe__f_perto_a_perto->joinWithAND(e_longe_d_longe, f_perto_a_perto);
  FuzzyRuleConsequent * entao_frente_f_i = new FuzzyRuleConsequent();
  entao_frente_f_i->addOutput(frente);
  FuzzyRule * Regra_72 = new FuzzyRule(72, e_longe_d_longe__f_perto_a_perto, entao_frente_f_i);
  fuzzy->addFuzzyRule(Regra_72);



  //FRENTE LONGE - ATRAS LONGE
  FuzzyRuleAntecedent * e_perto_d_perto__f_longe_a_longe = new FuzzyRuleAntecedent();
  e_perto_d_perto__f_perto_a_perto->joinWithAND(e_perto_d_perto, f_perto_a_perto);
  FuzzyRuleConsequent * entao_frente_g_a = new FuzzyRuleConsequent();
  entao_frente_g_a->addOutput(frente);
  FuzzyRule * Regra_73 = new FuzzyRule(73, e_perto_d_perto__f_perto_a_perto, entao_frente_g_a);
  fuzzy->addFuzzyRule(Regra_73);


  FuzzyRuleAntecedent * e_perto_d_medio__f_longe_a_longe = new FuzzyRuleAntecedent();
  e_perto_d_medio__f_perto_a_perto->joinWithAND(e_perto_d_medio, f_perto_a_perto);
  FuzzyRuleConsequent * entao_frente_g_b = new FuzzyRuleConsequent();
  entao_frente_g_b->addOutput(frente);
  entao_frente_g_b->addOutput(direita);
  FuzzyRule * Regra_74 = new FuzzyRule(74, e_perto_d_medio__f_perto_a_perto, entao_frente_g_b);
  fuzzy->addFuzzyRule(Regra_74);


  FuzzyRuleAntecedent * e_perto_d_longe__f_longe_a_longe = new FuzzyRuleAntecedent();
  e_perto_d_longe__f_perto_a_perto->joinWithAND(e_perto_d_longe, f_perto_a_perto);
  FuzzyRuleConsequent * entao_frente_g_c = new FuzzyRuleConsequent();
  entao_frente_g_c->addOutput(frente);
  entao_frente_g_c->addOutput(direita);
  FuzzyRule * Regra_75 = new FuzzyRule(75, e_perto_d_longe__f_perto_a_perto, entao_frente_g_c);
  fuzzy->addFuzzyRule(Regra_75);



  FuzzyRuleAntecedent * e_medio_d_perto__f_longe_a_longe = new FuzzyRuleAntecedent();
  e_medio_d_perto__f_perto_a_perto->joinWithAND(e_medio_d_perto, f_perto_a_perto);
  FuzzyRuleConsequent * entao_frente_g_d = new FuzzyRuleConsequent();
  entao_frente_g_d->addOutput(frente);
  entao_frente_g_d->addOutput(esquerda);
  FuzzyRule * Regra_76 = new FuzzyRule(76, e_medio_d_perto__f_perto_a_perto, entao_frente_g_d);
  fuzzy->addFuzzyRule(Regra_76);


  FuzzyRuleAntecedent * e_medio_d_medio__f_longe_a_longe = new FuzzyRuleAntecedent();
  e_medio_d_medio__f_perto_a_perto->joinWithAND(e_medio_d_medio, f_perto_a_perto);
  FuzzyRuleConsequent * entao_frente_g_e = new FuzzyRuleConsequent();
  entao_frente_g_e->addOutput(frente);
  FuzzyRule * Regra_77 = new FuzzyRule(77, e_medio_d_medio__f_perto_a_perto, entao_frente_g_e);
  fuzzy->addFuzzyRule(Regra_77);


  FuzzyRuleAntecedent * e_medio_d_longe__f_longe_a_longe = new FuzzyRuleAntecedent();
  e_medio_d_longe__f_perto_a_perto->joinWithAND(e_medio_d_longe, f_perto_a_perto);
  FuzzyRuleConsequent * entao_frente_g_f = new FuzzyRuleConsequent();
  entao_frente_g_f->addOutput(frente);
  FuzzyRule * Regra_78 = new FuzzyRule(78, e_medio_d_longe__f_perto_a_perto, entao_frente_g_f);
  fuzzy->addFuzzyRule(Regra_78);



  FuzzyRuleAntecedent * e_longe_d_perto__f_longe_a_longe = new FuzzyRuleAntecedent();
  e_longe_d_perto__f_perto_a_perto->joinWithAND(e_longe_d_perto, f_perto_a_perto);
  FuzzyRuleConsequent * entao_frente_g_g = new FuzzyRuleConsequent();
  entao_frente_g_g->addOutput(frente);
  entao_frente_g_g->addOutput(esquerda);
  FuzzyRule * Regra_79 = new FuzzyRule(79, e_longe_d_perto__f_perto_a_perto, entao_frente_g_g);
  fuzzy->addFuzzyRule(Regra_79);


  FuzzyRuleAntecedent * e_longe_d_medio__f_longe_a_longe = new FuzzyRuleAntecedent();
  e_longe_d_medio__f_perto_a_perto->joinWithAND(e_longe_d_medio, f_perto_a_perto);
  FuzzyRuleConsequent * entao_frente_g_h = new FuzzyRuleConsequent();
  entao_frente_g_h->addOutput(frente);
  FuzzyRule * Regra_80 = new FuzzyRule(80, e_longe_d_medio__f_perto_a_perto, entao_frente_g_h);
  fuzzy->addFuzzyRule(Regra_80);


  FuzzyRuleAntecedent * e_longe_d_longe__f_longe_a_longe = new FuzzyRuleAntecedent();
  e_longe_d_longe__f_perto_a_perto->joinWithAND(e_longe_d_longe, f_longe_a_longe);
  FuzzyRuleConsequent * entao_frente_g_i = new FuzzyRuleConsequent();
  entao_frente_g_i->addOutput(frente);
  FuzzyRule * Regra_81 = new FuzzyRule(81, e_longe_d_longe__f_longe_a_longe, entao_frente_g_i);
  fuzzy->addFuzzyRule(Regra_81);
}

void Distancia()
{ //SENSOR 1 - FRENTE
  digitalWrite(trigPin1, LOW); //não envia som
  delayMicroseconds(2);

  digitalWrite(trigPin1, HIGH); //envia som
  delayMicroseconds(10);

  digitalWrite(trigPin1, LOW); //não envia o som e espera o retorno do som enviado
  duracao1 = pulseIn(echoPin1, HIGH); //Captura a duração em tempo do retorno do som.

  HR_dist1 = duracao1 * 0.034 / 2; //Calcula a distância

  //SENSOR 2 - ATRAS
  digitalWrite(trigPin2, LOW); //não envia som
  delayMicroseconds(2);

  digitalWrite(trigPin2, HIGH); //envia som
  delayMicroseconds(10);

  digitalWrite(trigPin2, LOW); //não envia o som e espera o retorno do som enviado
  duracao2 = pulseIn(echoPin2, HIGH); //Captura a duração em tempo do retorno do som.

  HR_dist2 = duracao2 * 0.034 / 2; //Calcula a distância

  //SENSOR 3 - ESQUERDA
  digitalWrite(trigPin3, LOW); //não envia som
  delayMicroseconds(2);

  digitalWrite(trigPin3, HIGH); //envia som
  delayMicroseconds(10);

  digitalWrite(trigPin3, LOW); //não envia o som e espera o retorno do som enviado
  duracao3 = pulseIn(echoPin3, HIGH); //Captura a duração em tempo do retorno do som.

  HR_dist3 = duracao3 * 0.034 / 2; //Calcula a distância

  //SENSOR 4 - DIREITA
  digitalWrite(trigPin4, LOW); //não envia som
  delayMicroseconds(2);

  digitalWrite(trigPin4, HIGH); //envia som
  delayMicroseconds(10);

  digitalWrite(trigPin4, LOW); //não envia o som e espera o retorno do som enviado
  duracao4 = pulseIn(echoPin4, HIGH); //Captura a duração em tempo do retorno do som.

  HR_dist4 = duracao4 * 0.034 / 2; //Calcula a distância
}

void Velocidade() {
  analogWrite(vel4, 255);
  analogWrite(vel3, 255);
  analogWrite(vel2, 255);
  analogWrite(vel1, 255);
}

void Frente() {
  digitalWrite(e14, LOW); // MOTOR 4
  digitalWrite(e24, HIGH); // MOTOR 4

  digitalWrite(e13, LOW); // MOTOR 3
  digitalWrite(e23, HIGH); // MOTOR 3


  digitalWrite(e12, LOW); // MOTOR 2
  digitalWrite(e22, HIGH); // MOTOR 2

  digitalWrite(e11, LOW); // MOTOR 1
  digitalWrite(e21, HIGH);  // MOTOR 1
}

void Atras() {
  digitalWrite(e14, HIGH); // MOTOR 4
  digitalWrite(e24, LOW); // MOTOR 4

  digitalWrite(e13, HIGH); // MOTOR 3
  digitalWrite(e23, LOW); // MOTOR 3


  digitalWrite(e12, HIGH); // MOTOR 2
  digitalWrite(e22, LOW); // MOTOR 2

  digitalWrite(e11, HIGH); // MOTOR 1
  digitalWrite(e21, LOW);  // MOTOR 1
}

void Direita() {
  digitalWrite(e14, HIGH); // MOTOR 4
  digitalWrite(e24, LOW); // MOTOR 4

  digitalWrite(e13, LOW); // MOTOR 3
  digitalWrite(e23, HIGH); // MOTOR 3


  digitalWrite(e12, HIGH); // MOTOR 2
  digitalWrite(e22, LOW); // MOTOR 2

  digitalWrite(e11, LOW); // MOTOR 1
  digitalWrite(e21, HIGH);  // MOTOR 1
}

void Esquerda() {
  digitalWrite(e14, LOW); // MOTOR 4
  digitalWrite(e24, HIGH); // MOTOR 4

  digitalWrite(e13, HIGH); // MOTOR 3
  digitalWrite(e23, LOW); // MOTOR 3


  digitalWrite(e12, LOW); // MOTOR 2
  digitalWrite(e22, HIGH); // MOTOR 2

  digitalWrite(e11, HIGH); // MOTOR 1
  digitalWrite(e21, LOW);  // MOTOR 1
}

void Parado() {
  digitalWrite(e14, LOW); // MOTOR 4
  digitalWrite(e24, LOW); // MOTOR 4

  digitalWrite(e13, LOW); // MOTOR 3
  digitalWrite(e23, LOW); // MOTOR 3


  digitalWrite(e12, LOW); // MOTOR 2
  digitalWrite(e22, LOW); // MOTOR 2

  digitalWrite(e11, LOW); // MOTOR 1
  digitalWrite(e21, LOW);  // MOTOR 1
}

void loop() {
  fuzzy->setInput(1, HR_dist1);
  fuzzy->setInput(2, HR_dist2);
  fuzzy->setInput(3, HR_dist3);
  fuzzy->setInput(4, HR_dist4);

  fuzzy->fuzzify();

  float saida01 = fuzzy->defuzzify(1);
  float saida02 = fuzzy->defuzzify(2);

  Comandos();

  delay(500);
}

void Comandos () {
  bool chamando_regra_01 = fuzzy->isFiredRule(1);
  bool chamando_regra_02 = fuzzy->isFiredRule(2);
  bool chamando_regra_03 = fuzzy->isFiredRule(3);
  bool chamando_regra_04 = fuzzy->isFiredRule(4);
  bool chamando_regra_05 = fuzzy->isFiredRule(5);
  bool chamando_regra_06 = fuzzy->isFiredRule(6);
  bool chamando_regra_07 = fuzzy->isFiredRule(7);
  bool chamando_regra_08 = fuzzy->isFiredRule(8);
  bool chamando_regra_09 = fuzzy->isFiredRule(9);
  bool chamando_regra_10 = fuzzy->isFiredRule(10);
  bool chamando_regra_11 = fuzzy->isFiredRule(11);
  bool chamando_regra_12 = fuzzy->isFiredRule(12);
  bool chamando_regra_13 = fuzzy->isFiredRule(13);
  bool chamando_regra_14 = fuzzy->isFiredRule(14);
  bool chamando_regra_15 = fuzzy->isFiredRule(15);
  bool chamando_regra_16 = fuzzy->isFiredRule(16);
  bool chamando_regra_17 = fuzzy->isFiredRule(17);
  bool chamando_regra_18 = fuzzy->isFiredRule(18);
  bool chamando_regra_19 = fuzzy->isFiredRule(19);
  bool chamando_regra_20 = fuzzy->isFiredRule(20);
  bool chamando_regra_21 = fuzzy->isFiredRule(21);
  bool chamando_regra_22 = fuzzy->isFiredRule(22);
  bool chamando_regra_23 = fuzzy->isFiredRule(23);
  bool chamando_regra_24 = fuzzy->isFiredRule(24);
  bool chamando_regra_25 = fuzzy->isFiredRule(25);
  bool chamando_regra_26 = fuzzy->isFiredRule(26);
  bool chamando_regra_27 = fuzzy->isFiredRule(27);
  bool chamando_regra_28 = fuzzy->isFiredRule(28);
  bool chamando_regra_29 = fuzzy->isFiredRule(29);
  bool chamando_regra_30 = fuzzy->isFiredRule(30);
  bool chamando_regra_31 = fuzzy->isFiredRule(31);
  bool chamando_regra_32 = fuzzy->isFiredRule(32);
  bool chamando_regra_33 = fuzzy->isFiredRule(33);
  bool chamando_regra_34 = fuzzy->isFiredRule(34);
  bool chamando_regra_35 = fuzzy->isFiredRule(35);
  bool chamando_regra_36 = fuzzy->isFiredRule(36);
  bool chamando_regra_37 = fuzzy->isFiredRule(37);
  bool chamando_regra_38 = fuzzy->isFiredRule(38);
  bool chamando_regra_39 = fuzzy->isFiredRule(39);
  bool chamando_regra_40 = fuzzy->isFiredRule(40);
  bool chamando_regra_41 = fuzzy->isFiredRule(41);
  bool chamando_regra_42 = fuzzy->isFiredRule(42);
  bool chamando_regra_43 = fuzzy->isFiredRule(43);
  bool chamando_regra_44 = fuzzy->isFiredRule(44);
  bool chamando_regra_45 = fuzzy->isFiredRule(45);
  bool chamando_regra_46 = fuzzy->isFiredRule(46);
  bool chamando_regra_47 = fuzzy->isFiredRule(47);
  bool chamando_regra_48 = fuzzy->isFiredRule(48);
  bool chamando_regra_49 = fuzzy->isFiredRule(49);
  bool chamando_regra_50 = fuzzy->isFiredRule(50);
  bool chamando_regra_51 = fuzzy->isFiredRule(51);
  bool chamando_regra_52 = fuzzy->isFiredRule(52);
  bool chamando_regra_53 = fuzzy->isFiredRule(53);
  bool chamando_regra_54 = fuzzy->isFiredRule(54);
  bool chamando_regra_55 = fuzzy->isFiredRule(55);
  bool chamando_regra_56 = fuzzy->isFiredRule(56);
  bool chamando_regra_57 = fuzzy->isFiredRule(57);
  bool chamando_regra_58 = fuzzy->isFiredRule(58);
  bool chamando_regra_59 = fuzzy->isFiredRule(59);
  bool chamando_regra_60 = fuzzy->isFiredRule(60);
  bool chamando_regra_61 = fuzzy->isFiredRule(61);
  bool chamando_regra_62 = fuzzy->isFiredRule(62);
  bool chamando_regra_63 = fuzzy->isFiredRule(63);
  bool chamando_regra_64 = fuzzy->isFiredRule(64);
  bool chamando_regra_65 = fuzzy->isFiredRule(65);
  bool chamando_regra_66 = fuzzy->isFiredRule(66);
  bool chamando_regra_67 = fuzzy->isFiredRule(67);
  bool chamando_regra_68 = fuzzy->isFiredRule(68);
  bool chamando_regra_69 = fuzzy->isFiredRule(69);
  bool chamando_regra_70 = fuzzy->isFiredRule(70);
  bool chamando_regra_71 = fuzzy->isFiredRule(71);
  bool chamando_regra_72 = fuzzy->isFiredRule(72);
  bool chamando_regra_73 = fuzzy->isFiredRule(73);
  bool chamando_regra_74 = fuzzy->isFiredRule(74);
  bool chamando_regra_75 = fuzzy->isFiredRule(75);
  bool chamando_regra_76 = fuzzy->isFiredRule(76);
  bool chamando_regra_77 = fuzzy->isFiredRule(77);
  bool chamando_regra_78 = fuzzy->isFiredRule(78);
  bool chamando_regra_79 = fuzzy->isFiredRule(79);
  bool chamando_regra_80 = fuzzy->isFiredRule(80);
  bool chamando_regra_81 = fuzzy->isFiredRule(81);

  if (chamando_regra_01 == true) {
    Parado();
  }
  else if (chamando_regra_02 == true) {
    Parado();
  }
  else if (chamando_regra_03 == true) {
    Parado();
  }
  else if (chamando_regra_04 == true) {
    Parado();
  }
  else if (chamando_regra_05 == true) {
    Parado();
  }
  else if (chamando_regra_06 == true) {
    Parado();
  }
  else if (chamando_regra_07 == true) {
    Parado();
  }
  else if (chamando_regra_08 == true) {
    Parado();
  }
  else if (chamando_regra_09 == true) {
    Parado();
  }
  else if (chamando_regra_10 == true) {
    Frente();
  }
  else if (chamando_regra_11 == true) {
    Direita();
  }
  else if (chamando_regra_12 == true) {
    Direita();
  }
  else if (chamando_regra_13 == true) {
    Esquerda();
  }
  else if (chamando_regra_14 == true) {
    Frente();
  }
  else if (chamando_regra_15 == true) {
    Frente();
  }
  else if (chamando_regra_16 == true) {
    Esquerda();
  }
  else if (chamando_regra_17 == true) {
    Frente();
  }
  else if (chamando_regra_18 == true) {
    Frente();
  }
  else if (chamando_regra_19 == true) {
    Frente();
  }
  else if (chamando_regra_20 == true) {
    Direita();
  }
  else if (chamando_regra_21 == true) {
    Direita();
  }
  else if (chamando_regra_22 == true) {
    Esquerda();
  }
  else if (chamando_regra_23 == true) {
    Frente();
  }
  else if (chamando_regra_24 == true) {
    Frente();
  }
  else if (chamando_regra_25 == true) {
    Esquerda();
  }
  else if (chamando_regra_26 == true) {
    Frente();
  }
  else if (chamando_regra_27 == true) {
    Frente();
  }
  else if (chamando_regra_28 == true) {
    Frente();
  }
  else if (chamando_regra_29 == true) {
    Direita();
  }
  else if (chamando_regra_30 == true) {
    Direita();
  }
  else if (chamando_regra_31 == true) {
    Esquerda();
  }
  else if (chamando_regra_32 == true) {
    Frente();
  }
  else if (chamando_regra_33 == true) {
    Frente();
  }
  else if (chamando_regra_34 == true) {
    Esquerda();
  }
  else if (chamando_regra_35 == true) {
    Frente();
  }
  else if (chamando_regra_36 == true) {
    Frente();
  }
  else if (chamando_regra_37 == true) {
    Frente();
  }
  else if (chamando_regra_38 == true) {
    Direita();
  }
  else if (chamando_regra_39 == true) {
    Frente();
  }
  else if (chamando_regra_40 == true) {
    Frente();
  }
  else if (chamando_regra_41 == true) {
    Frente();
  }
  else if (chamando_regra_42 == true) {
    Frente();
  }
  else if (chamando_regra_43 == true) {
    Esquerda();
  }
  else if (chamando_regra_44 == true) {
    Frente();
  }
  else if (chamando_regra_45 == true) {
    Frente();
  }
  else if (chamando_regra_46 == true) {
    Frente();
  }
  else if (chamando_regra_47 == true) {
    Direita();
  }
  else if (chamando_regra_48 == true) {
    Direita();
  }
  else if (chamando_regra_49 == true) {
    Esquerda();
  }
  else if (chamando_regra_50 == true) {
    Frente();
  }
  else if (chamando_regra_51 == true) {
    Frente();
  }
  else if (chamando_regra_52 == true) {
    Esquerda();
  }
  else if (chamando_regra_53 == true) {
    Frente();
  }
  else if (chamando_regra_54 == true) {
    Frente();
  }
  else if (chamando_regra_55 == true) {
    Atras();
  }
  else if (chamando_regra_56 == true) {
    Atras();
  }
  else if (chamando_regra_57 == true) {
    Atras();
  }
  else if (chamando_regra_58 == true) {
    Atras();
  }
  else if (chamando_regra_59 == true) {
    Atras();
  }
  else if (chamando_regra_60 == true) {
    Atras();
  }
  else if (chamando_regra_61 == true) {
    Atras();
  }
  else if (chamando_regra_62 == true) {
    Atras();
  }
  else if (chamando_regra_63 == true) {
    Frente();
  }
  else if (chamando_regra_64 == true) {
    Frente();
  }
  else if (chamando_regra_65 == true) {
    Direita();
  }
  else if (chamando_regra_66 == true) {
    Direita();
  }
  else if (chamando_regra_67 == true) {
    Esquerda();
  }
  else if (chamando_regra_68 == true) {
    Frente();
  }
  else if (chamando_regra_69 == true) {
    Frente();
  }
  else if (chamando_regra_70 == true) {
    Esquerda();
  }
  else if (chamando_regra_71 == true) {
    Frente();
  }
  else if (chamando_regra_72 == true) {
    Frente();
  }
  else if (chamando_regra_73 == true) {
    Frente();
  }
  else if (chamando_regra_74 == true) {
    Direita();
  }
  else if (chamando_regra_75 == true) {
    Direita();
  }
  else if (chamando_regra_76 == true) {
    Esquerda();
  }
  else if (chamando_regra_77 == true) {
    Frente();
  }
  else if (chamando_regra_78 == true) {
    Frente();
  }
  else if (chamando_regra_79 == true) {
    Esquerda();
  }
  else if (chamando_regra_80 == true) {
    Frente();
  }
  else if (chamando_regra_81 == true) {
    Frente();
  }
}`Texto pré-formatado`

Olá,

Que saída? Porque dizes que não funciona?

Edita a mensagem anterior para formatar o código para ficar mais fácil de perceber. Coloca três acentos graves antes e depois do código. Ou então pressiona no botão </> (ou Ctrl+E) e cola o código.

não está saindo nada, era para o carrinho andar e desviar dos objetos mas, os motores não funciona o arduino não manda sinal para as pontes H e quando peço para ver as medidas através dos sensores HC-SR04 tambem não lê. Estou usando 4 ultrassônicos, 2 ponte H L298N.

De onde copiaste o código? Testaste os motores e os sensores em separado antes de colocares este código no Arduino?

Se não testaste cada parte individualmente, então começa por aí para teres a certeza que as ligações estão correctas e passa depois para o programa no Arduino com fuzzy logic.

Por curiosidade, que é que sabes de fuzzy logic?

Boa Tarde, Não copiei. Fiz esse código interpretando artigos que achei disponíveis na internet.
As ligações estão corretas fiz um código para testar os motores e deu certo e fiz outro para testar os sensores e deu certo. No código que coloquei aqui busquei seguir a estruturas que interpretei.
Sobre logica fuzzy eu sei muito pouco, eu sei que ela é diferente de uma rede perceptron multicamadas, onde na perceptron primeiro você tem que ensinar o neurônio que fazer procurando uma taxa de aprendizagem, algo que não é necessário na fuzzy, onde ela atua de modo aprimorado, tendo mais respostas que simples 0 ou 1.

Se eu tiver errado, por favor me corrija, pois achei que fosse assim o modus operandi da Fuzzy.

A função Distancia() calcula as distâncias mas não é executada em lado nenhum.

Coloca-a no loop() para ir actualizando as variáveis HR_dist1, HR_dist2, HR_dist3 e HR_dist4.

void loop() {
  Distancia();  // <-- Actualiza as variáveis HR_dist.
  fuzzy->setInput(1, HR_dist1);
  fuzzy->setInput(2, HR_dist2);
  fuzzy->setInput(3, HR_dist3);
  fuzzy->setInput(4, HR_dist4);

  fuzzy->fuzzify();

  float saida01 = fuzzy->defuzzify(1);
  float saida02 = fuzzy->defuzzify(2);

  Comandos();

  delay(500);
}

Edit: A função Velocidade() também não parece ser utilizada. Penso que tem de ser chamada para accionar o PWM nos motores.

Boa Noite,

Testei aqui e as medidas funcionou, porem os motores ainda não mas, muito obrigado mesmo um problema já está resolvido, falta só os motores agora.
a função Velocidade é para acionar os PWM mesmo. Vou começar a comentar as linhas para ficar mais fácil o entendimento

Penso que se executares a função Velocidade() os motores devem rodar. Experimenta a chamá-la no setup() para testar.

Boa noite,

Primeiramente gostaria muito de agradecer a sua ajuda, hoje foi a apresentação do trabalho e consegui uma nota muito boa.

Os motores não funcionaram com a Fuzzy, porem mostrei o código e o meu professor tambem não achou erro.

Não desisti dele, porem agora vou faze-lo nas horas vagas.

Segue uma foto do truck.

1 Like

Parabéns :smiley: :+1: :+1:

Talvez seja boa ideia tentar com um programa mais simples para facilitar perceber onde possa estar o problema...

Boa noite @suethamhenrique ,
gostei muito deste seu caminhão.
Estou fazendo um projeto para meus netos e estou tendo que construir o caminhão inteiro.
Mas ao ver o seu caminhão , talvez eu consiga usa-lo para meu proposito.
Caso não tenha sido construído pelo Sr. (a parte plástica), , por gentileza, poderia informar onde adquiriu este caminhão?

Atenciosamente.

RV mineirin

Boa Tarde,

a parte plástica comprei em loja de brinquedo, ai as rodas são as que veio junto com o motor. Para dar certo tive que cortar algumas partes embaixo para dar certo.

Tks for your attention.
This is my project still in progress.

RV mineirin

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.