Problems with line follower

Hi, sorry if I have not chosen correctly the topic of my problem. The thing is that I am testing with my line follower, made with Arduino UNO. I made the code, also the wiring and the whole thing. Now, the problem is that when I go to turn it on, directly the wheels don't move even though the sensors and everything else seems to be in correct operation.

I attach my code, maybe someone can tell me why it happens as it happens (I already did a basic check to detect the problem, I checked if things were well connected and so on, but maybe I missed something).

//Motor izquierdo
int in1 = 5;
int in2 = 6;
int ena = 10;

//Motor derecho:
int in3 = 4;
int in4 = 3;
int enb = 11;

//Sensor izquierdo
int sensorizquierdo = A1;
int senizq;

//Sensor derecho
int sensorderecho = A0;
int sender;

//Velocidad lineal
int velolineal = 190;

//Velocidad de giro
int velogiro = 190;

//Umbral de los visores
int umizq = 550;
int umder = 550;

void setup()
{
   pinMode (in1, OUTPUT);
   pinMode (in1, OUTPUT);
   pinMode (in3, OUTPUT);
   pinMode (in4, OUTPUT);
   pinMode (ena, OUTPUT);
   pinMode (enb, OUTPUT);

   Serial.begin(9600);
}

void loop(){
   lectura();
  if (sensorizquierdo>umizq &&
      sensorderecho>umder){
      adelante();
  }else if (sensorizquierdo<umizq &&
              sensorderecho<umder){
      frenar();
  }else if (sensorizquierdo>umizq &&
              sensorderecho<umder){
      izq();
  }else if (sensorizquierdo<umizq &&
              sensorderecho>umder){
      der();
  }else if (sensorizquierdo>umizq &&
              sensorderecho<umder){
  }
}
void lectura(){
   senizq= analogRead (sensorizquierdo);
   sender= analogRead (sensorderecho);

   }
void adelante()
{

//motor izquierdo
digitalWrite(in1,HIGH);
digitalWrite(in2,LOW);
analogWrite(ena,velolineal);
//motor derecho
digitalWrite(in3,HIGH);
digitalWrite(in4,LOW);
analogWrite(enb,velolineal);

}


void frenar()
{

//motor izquierdo
digitalWrite(in1,LOW);
digitalWrite(in2,LOW);
analogWrite(ena,velolineal);
//motor derecho
digitalWrite(in3,LOW);
digitalWrite(in4,LOW);
analogWrite(enb,velolineal);

}

void der()
{
//motor izquierdo
digitalWrite(in1,HIGH);
digitalWrite(in2,LOW);
analogWrite(ena,velogiro);
//motor derecho
digitalWrite(in3,LOW);
digitalWrite(in4,LOW);
analogWrite(enb,velogiro);
}

void izq()
{
//motor izquierdo
digitalWrite(in1,LOW);
digitalWrite(in2,LOW);
analogWrite(ena,velogiro);
//motor derecho
digitalWrite(in3,HIGH);
digitalWrite(in4,LOW);
analogWrite(enb,velogiro);
}

I have deleted your other cross-post @soappopo.

Cross-posting is against the Arduino forum rules. The reason is that duplicate posts can waste the time of the people trying to help. Someone might spend a lot of time investigating and writing a detailed answer on one topic, without knowing that someone else already did the same in the other topic.

Repeated cross-posting can result in a suspension from the forum.

In the future, please only create one topic for each distinct subject matter. This is basic forum etiquette, as explained in the "How to get the best out of this forum" guide. It contains a lot of other useful information. Please read it.

Thanks in advance for your cooperation.

Check your power supply.

Also... this...

if (sensorizquierdo...

will always be "15" and...

if (sensorderecho...

will always be "14" because...

//Sensor izquierdo
int sensorderecho = A0; // A0 is Digital Pin 14
int sensorizquierdo = A1; // A1 is Digital Pin 15

You should use the analogRead... in lectura()... if (senizq...

void lectura(){
   senizq= analogRead (sensorizquierdo);

Same with sensorderecho... use if (sender...

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