L298N Arduino Motor Driver Shield and ethernet shield wont work!!!!!!

Hello everyone I have: Arduino Mega ethernet shield L298N Arduino Motor Driver Shield

connected in that order since I put in the middle the ethernet shield my motors wont work. I can't find any pin to run motors Help please Thanks

//Motor  RX;
int dir1PinA = 13;
int dir2PinA = 12;// FWD
int speedPinA = A0;

//motor LX;
int dir1PinB = 11;
int dir2PinB = 8;// FWD
int speedPinB = A1;



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


  pinMode(dir2PinA,OUTPUT);

  pinMode (dir1PinA, OUTPUT);
  
  pinMode (speedPinA, OUTPUT);
  
  pinMode (dir1PinB, OUTPUT);
  
  pinMode (dir2PinB, OUTPUT);
  
  pinMode (speedPinB, OUTPUT);

}

//----------------motors functions

void forward()
{

  digitalWrite (dir1PinA, LOW);// right motor
  digitalWrite (dir2PinA, HIGH);
  digitalWrite (dir1PinB, LOW);// lx motor
  digitalWrite (dir2PinB, HIGH);
  analogWrite(speedPinA, 1023);
  analogWrite(speedPinB, 1023);
  //delay(10);

}

void backward()
{

  analogWrite(speedPinA, 1024);
  analogWrite(speedPinB, 1024);
  digitalWrite (dir1PinA, HIGH);
  digitalWrite (dir2PinA, LOW);
  digitalWrite (dir1PinB, HIGH);
  digitalWrite (dir2PinB, LOW);
  //delay(10);
}


void left()
{
  analogWrite(speedPinA, 1024);
  analogWrite(speedPinB, 0);
  digitalWrite (dir1PinA, LOW);
  digitalWrite (dir2PinA, HIGH);
  digitalWrite (dir1PinB, LOW);
  digitalWrite (dir2PinB, LOW);
  //delay(10);
}

void right()
{
  analogWrite(speedPinA, 0);
  analogWrite(speedPinB, 1024);
  digitalWrite (dir1PinA, LOW);
  digitalWrite (dir2PinA, LOW);
  digitalWrite (dir1PinB, LOW);
  digitalWrite (dir2PinB, HIGH);
  //delay(10);
}

void stopM()
{
  analogWrite(speedPinA, 0);
  analogWrite(speedPinB, 0);
  //digitalWrite (dir1PinA, LOW);
  //digitalWrite (dir2PinA, LOW);
  //digitalWrite (dir1PinB, LOW);
  //digitalWrite (dir2PinB, LOW);
  //delay(10);
}

void rightBACK()// ----------------------BACK RIGHT
{
  analogWrite(speedPinA, 0);
  analogWrite(speedPinB, 1024);
  digitalWrite (dir1PinA, LOW);
  digitalWrite (dir2PinA, LOW);
  digitalWrite (dir1PinB, HIGH);
  digitalWrite (dir2PinB, LOW);
  //delay(10);
}

void leftBACK() //-----------------------BACK LEFT
{
  analogWrite(speedPinA, 1024);
  analogWrite(speedPinB, 0);
  digitalWrite (dir1PinA, HIGH);
  digitalWrite (dir2PinA, LOW);
  digitalWrite (dir1PinB, LOW);
  digitalWrite (dir2PinB, LOW);
  //delay(10);
}

//-----------------end motors function------------------------

void loop() {
  // put your main code here, to run repeatedly: 
  int sensorValue1 = digitalRead(dir1PinA);
  int sensorValue2 = digitalRead(dir2PinA);// ON
  int sensorValue3 = analogRead(speedPinA);// 1023
  int sensorValue4 = digitalRead(dir1PinB);
  int sensorValue5 = digitalRead(dir2PinB);// ON
  int sensorValue6 = analogRead(speedPinB);// 1023
  
  
  forward();
  Serial.print(sensorValue1);
  Serial.print(sensorValue2);
  
  Serial.print(sensorValue4);
  Serial.print(sensorValue5);
  
  Serial.print(" / ");
  Serial.print(sensorValue3, DEC);
  Serial.print(" / ");
  Serial.println(sensorValue6, DEC);
  delay(1000);
  
  
  
//Serial.println(buttonState);

/*backward();

  Serial.print(sensorValue1);
  Serial.print(sensorValue2);
  
  Serial.print(sensorValue4);
  Serial.print(sensorValue5);
  
  Serial.print(" / ");
  Serial.print(sensorValue3, DEC);
  Serial.print(" / ");
  Serial.println(sensorValue6, DEC);
delay(1000);


stopM();
  
  Serial.print(sensorValue1);
  Serial.print(sensorValue2);
  
  Serial.print(sensorValue4);
  Serial.print(sensorValue5);
  
  Serial.print(" / ");
  Serial.print(sensorValue3, DEC);
  Serial.print(" / ");
  Serial.println(sensorValue6, DEC);

delay(1000);
*/
}

Doesn't that ethernet shield totally hose the 5V?

My motors get power from a battery pack I actually need to know which pins of the motor shield are used to communicate with arduino mega so I will wiring it separately. I am trying to find a board diagram

Should be the same, transferable, as your sketch is all digitalWrite and so on (all the INO/PDE stuff).

Maybe your “ethernet shield” (Which?) doesn’t actually bring all those pins through its top headers.

Ehm, you are trying to output an analog value on the analog [u]inputs[/u] A0 and A1. You should use PWM outputs for that... On the Arduino MEGA, you can use the pins 2 to 13 or 44 to 46 for PWM.

Also, keep in mind that the analog output is 8-bit, so it can handle values ranging from 0 to 255.

Also, you are trying to do digitalRead() and analogRead() on [u]output[/u] pins. That won't work either. What is the purpose of this? If you want to know the current state of the output, I suggest you do this: after you say, for instance, digitalWrite(output1,HIGH);, you also say output1stateTracker = TRUE;.

in the header, you add boolean output1stateTracker;

To request the current state of the outputs, all you have to do is Serial.print(output1stateTracker);

Note that you have to do this for all 6 outputs. The analog output stateTrackers should be bytes, because of the 8-bit value.

I didn't go into it as deeply as muddy has.

Given

bobafet67: since I put in the middle the ethernet shield my motors wont work.

I assumed that a previously satisfactory situation changed with the introduction of this "ethernet shield".

Sometimes (so often)... it's like peeling onions.

Check and see if the motor shield and Ethernet shields are trying to use some of the same pins.