71-2WD araba ışık izleyen

2WD araba ışık izleyen
					

int sagldr = A2;
int ortaldr = A1;
int solldr = A0;

int sagldrdeger =0;
int ortaldrdeger =0;
int solldrdeger =0;

void setup() {
      Serial.begin(9600);
}
void dur()
    {
        analogWrite(5,0);
        analogWrite(6,0);
        analogWrite(9,0);
        analogWrite(10,0);
    }

void ileri()
    {
        analogWrite(5,255);
        analogWrite(6,0);
        analogWrite(9,0);
        analogWrite(10,255);
    }

void geri()
    {
        analogWrite(5,0);
        analogWrite(6,255);
        analogWrite(9,255);
        analogWrite(10,0);
    }

void sag()
    {
        analogWrite(5,0);
        analogWrite(6,0);
        analogWrite(9,0);
        analogWrite(10,255);
    }

void sol()
    {
        analogWrite(5,255);
        analogWrite(6,0);
        analogWrite(9,0);
        analogWrite(10,0);
    }

void loop() {
  sagldrdeger = analogRead(sagldr);
  ortaldrdeger = analogRead(ortaldr);
  solldrdeger = analogRead(solldr);

  Serial.print(solldrdeger);
  Serial.print("-");
  Serial.print(ortaldrdeger);
  Serial.print("-");
  Serial.print(sagldrdeger);
  Serial.println("-");

  if(ortaldrdeger > sagldrdeger && ortaldrdeger > solldrdeger)
    {
        ileri();
    }
  else if(solldrdeger > sagldrdeger && solldrdeger > ortaldrdeger)
    {
        sol();
    }
  else if(sagldrdeger > solldrdeger && sagldrdeger > ortaldrdeger)
    {
        sag();
    }
  else
    {
        dur();
    }

}