User:Khaifuture/ENES-100/Project 1: Maze Solver

Week0 Narrative
Assigned project:

Week1 Narrative
(Understanding this code)

int LightValueA0; // The value from the sensor (0..1023)
 * 1) define SENSOR_PINA0 A0
 * 2) define SENSOR_PINA1 A1

int LightValueA1; // The value from the sensor (0..1023)

int ENA=5;//connected to Arduino's port 5(output pwm)

int IN1=2;//connected to Arduino's port 2 DIRA

int IN2=3;//connected to Arduino's port 3 DIR#A -- Motor A Brake

int ENB=6;//connected to Arduino's port 6(output pwm)

int IN3=4;//connected to Arduino's port 4 DIRB

int IN4=7;//connected to Arduino's port 7 DIR#B -- Motor B Brake

void setup { Serial.begin (115200); pinMode(ENA,OUTPUT);//output pinMode(ENB,OUTPUT); pinMode(IN1,OUTPUT); pinMode(IN2,OUTPUT); pinMode(IN3,OUTPUT); pinMode(IN4,OUTPUT); digitalWrite(ENA,LOW); digitalWrite(ENB,LOW);//stop driving }

void loop { {   LightValueA0 = analogRead(SENSOR_PINA0);  //Read the voltage from sensor Serial.println(LightValueA0,DEC);     // Send result to Serial Monitor delay(100); LightValueA1 = analogRead(SENSOR_PINA1); //Read the voltage from sensor Serial.println(LightValueA1,DEC);     // Send result to Serial Monitor delay(100); if (analogRead(SENSOR_PINA0) >= 900 && analogRead(SENSOR_PINA1) >= 900) {digitalWrite(9, HIGH);  // set the LED on    delay(100);              // wait for a second digitalWrite(9, LOW);   // set the LED off delay(100);             // wait for a second analogWrite(ENA,200);//start driving motorA analogWrite(ENB,230);//start driving motorB digitalWrite(IN1,LOW); digitalWrite(IN2,HIGH);//setting motorA's directon digitalWrite(IN3,HIGH); digitalWrite(IN4,LOW);//setting motorB's directon delay(200); analogWrite(ENA,200);//start driving motorA analogWrite(ENB,230);//start driving motorB digitalWrite(IN1,LOW); digitalWrite(IN2,LOW);//setting motorA's directon digitalWrite(IN3,LOW); digitalWrite(IN4,LOW);//setting motorB's directon delay(50); }   if (analogRead(SENSOR_PINA0) >= 900 && analogRead(SENSOR_PINA1) <= 900) {   analogWrite(ENA,180);//start driving motorA analogWrite(ENB,230);//start driving motorB digitalWrite(IN1,LOW); digitalWrite(IN2,HIGH);//setting motorA's directon digitalWrite(IN3,LOW); digitalWrite(IN4,HIGH);//setting motorB's directon delay(100); analogWrite(ENA,200);//start driving motorA analogWrite(ENB,230);//start driving motorB digitalWrite(IN1,LOW); digitalWrite(IN2,LOW);//setting motorA's directon digitalWrite(IN3,LOW); digitalWrite(IN4,LOW);//setting motorB's directon delay(50); } {    if (analogRead(SENSOR_PINA0) <= 900 && analogRead(SENSOR_PINA1) >= 900) {   analogWrite(ENA,230);//start driving motorA analogWrite(ENB,180);//start driving motorB digitalWrite(IN1,HIGH); digitalWrite(IN2,LOW);//setting motorA's directon digitalWrite(IN3,HIGH); digitalWrite(IN4,LOW);//setting motorB's directon delay(100); analogWrite(ENA,200);//start driving motorA analogWrite(ENB,230);//start driving motorB digitalWrite(IN1,LOW); digitalWrite(IN2,LOW);//setting motorA's directon digitalWrite(IN3,LOW); digitalWrite(IN4,LOW);//setting motorB's directon delay(50); } {    if (analogRead(SENSOR_PINA0) <= 900 && analogRead(SENSOR_PINA1) <= 900) {   analogWrite(ENA,230);//start driving motorA analogWrite(ENB,230);//start driving motorB digitalWrite(IN1,LOW); digitalWrite(IN2,LOW);//setting motorA's directon digitalWrite(IN3,LOW); digitalWrite(IN4,LOW);//setting motorB's directon delay(100); } delay(100); }}}}

What I don't understand here is that, it has 2motors. This is so confusing.