Motor Control Not working

Arduino Uno with Ethernet Shield

I am trying to connect my motors to two buttons on the app, here is my code, I know I have the connections on the board lined up with the code, and the wiring is all right because I checked with some manual code first. However when I upload the code to my Arduino, one motor turns on, and the other does nothing, and pressing the buttons doesn’t do anything. The print statements work fine so I know that is working.

#define BLYNK_PRINT Serial


#include <SPI.h>
#include <Ethernet.h>
#include <BlynkSimpleEthernet.h>

char auth[] = "mXLAzpfNR_EcosSKfdu68nJf8KNa81_1";

#define W5100_CS  10
#define SDCARD_CS 4
 

// Attach virtual serial terminal to Virtual Pin V1
WidgetTerminal terminal(V2);

// You can send commands from Terminal to your hardware. Just use
// the same Virtual Pin as your Terminal Widget

//Motor A
const int motorPin1  = 10;  
const int motorPin2  = 9;  
//Motor B
const int motorPin3  = 5;
const int motorPin4  = 6; 

void setup()
{
  // Debug console
  Serial.begin(9600);

  //Set pins as outputs
    pinMode(motorPin1, OUTPUT);
    pinMode(motorPin2, OUTPUT);
    pinMode(motorPin3, OUTPUT);
    pinMode(motorPin4, OUTPUT);

    digitalWrite(motorPin1,LOW);
    digitalWrite(motorPin2,LOW);
    digitalWrite(motorPin3,LOW);
    digitalWrite(motorPin4,LOW);
    
  pinMode(SDCARD_CS, OUTPUT);
  digitalWrite(SDCARD_CS, HIGH); // Deselect the SD card
  Blynk.begin(auth);
    // Clear the terminal content
  terminal.clear();

  // This will print Blynk Software version to the Terminal Widget when
  // your hardware gets connected to Blynk Server
  terminal.println(F("Blynk v" BLYNK_VERSION ": Device started"));
  terminal.println(F("-------------"));
  terminal.println(F("Type 'Marco' and get a reply, or type"));
  terminal.println(F("anything else and get it printed back."));
  terminal.flush();


}


//FORWARDS
BLYNK_WRITE(V0){
    int button = param.asInt(); // read button
    if (button == 1) {
    Serial.println("Moving forward");
    digitalWrite(motorPin1,LOW);
    digitalWrite(motorPin2,LOW);
    digitalWrite(motorPin3,LOW);
    digitalWrite(motorPin4,LOW);
    
  }
  else {
    Serial.println("Stop");
    digitalWrite(motorPin1,LOW);
    digitalWrite(motorPin2,LOW);
    digitalWrite(motorPin3,LOW);
    digitalWrite(motorPin4,LOW);
  }
}

//BACKWARDS
BLYNK_WRITE(V1){
    int button = param.asInt(); // read button
    if (button == 1) {
    Serial.println("Moving backward");
    digitalWrite(motorPin1,LOW);
    digitalWrite(motorPin2,LOW);
    digitalWrite(motorPin3,LOW);
    digitalWrite(motorPin4,LOW);
  }
  else {
    Serial.println("Stop");
    digitalWrite(motorPin1,LOW);
    digitalWrite(motorPin2,LOW);
    digitalWrite(motorPin3,LOW);
    digitalWrite(motorPin4,LOW);
  }
}




void loop()
{
  Blynk.run();
}

Hi @Kunal_Roy , I can see two problems here.

1- Same pin definition for W5100 and Motor A:

#define W5100_CS 10 
Motor A const int motorPin1 = 10;

2- Are you feeding your motor directly from Arduino??? Please, use a Motor Drive Controller board like the L298N, L293D or similar…

Regards,

Jose

GPIO10 is connected internally between the Arduino and the Ethernet shield and is used as the Chip Select (CS) for the Ethernet functionality.
You cant also use that pin for your motor control.

Pete.

Thanks! I am using an H bridge

Thanks!