The Serial Monitor does not display anything (Use Blynk app to control the car with Arduino Mega 2560, ESP8266 và L293D Motor Shield)

Chào mọi người ạ. Em đang làm ô tô điều khiển từ xa qua app Blynk, sử dụng Arduino Mega 2560, module ESP 8266, và Motor Shield L293D. và đây là Code của e ạ. Có ai đã từng làm hay rành về phần này cho e hỏi chút đc k ạ? khi Upload k có vấn đề gì mà khi mở Serial Monitor chả hiện ra gì cả.
When I opened the Serial Monitor, it does not display anything.


#define BLYNK_PRINT Serial2 
#include <ESP8266_Lib.h> 
#include <BlynkSimpleShieldEsp8266.h> 
char auth[] = "52e6da454cxxxxxxxxxxfbd8295263cdc";
char ssid[] = "ss407";
char pass[] = "12345678";

#include<AFMotor.h>
AF_DCMotor motor1(1, MOTOR12_64KHZ);
AF_DCMotor motor2(2, MOTOR12_64KHZ);
AF_DCMotor motor3(3, MOTOR12_64KHZ);
AF_DCMotor motor4(4, MOTOR12_64KHZ);

#define EspSerial Serial1
ESP8266 wifi(&EspSerial);
#define ESP8266_BAUD 115200

void setup() {
  Serial2.begin(9600);
  Serial.begin(9600);
  Serial.println("Hello");
  EspSerial.begin(ESP8266_BAUD);
  delay(10);
  Blynk.begin(auth, wifi, ssid, pass);
  // put your setup code here, to run once:
}
void motorForward(){
  motor1.setSpeed(95);
    motor1.run(FORWARD);
  motor2.setSpeed(95);
    motor2.run(FORWARD);
  motor3.setSpeed(95);
    motor3.run(FORWARD);
  motor4.setSpeed(95);
    motor4.run(FORWARD);
  }
void motorBackward(){
  motor1.setSpeed(95);
    motor1.run(BACKWARD);
  motor2.setSpeed(95);
    motor2.run(BACKWARD);
  motor3.setSpeed(95);
    motor3.run(BACKWARD);
  motor4.setSpeed(95);
    motor4.run(BACKWARD);
  }  
void motorTurnLeft(){
  motor1.run(RELEASE);
  motor2.run(RELEASE);
  motor3.setSpeed(95);
  motor4.setSpeed(95);
  motor3.run(FORWARD);
  motor4.run(FORWARD);
  }
void motorTurnRight(){
  motor1.setSpeed(95);
  motor2.setSpeed(95);
  motor1.run(FORWARD);
  motor2.run(FORWARD);
  motor3.run(RELEASE);
  motor4.run(RELEASE);
  }
void motorLeftBack(){
  motor1.setSpeed(50);
    motor1.run(BACKWARD);
  motor2.setSpeed(50);
    motor2.run(BACKWARD);
  motor3.setSpeed(95);
    motor3.run(BACKWARD);
  motor4.setSpeed(95);
    motor4.run(BACKWARD);
  }
void motorRightBack(){
  motor1.setSpeed(95);
    motor1.run(BACKWARD);
  motor2.setSpeed(95);
    motor2.run(BACKWARD);
  motor3.setSpeed(50);
    motor3.run(BACKWARD);
  motor4.setSpeed(50);
    motor4.run(BACKWARD);
  }
void motorLeftForward(){
  motor1.setSpeed(50);
    motor1.run(FORWARD);
  motor2.setSpeed(50);
    motor2.run(FORWARD);
  motor3.setSpeed(95);
    motor3.run(FORWARD);
  motor4.setSpeed(95);
    motor4.run(FORWARD);
  }
void motorRightForward(){
  motor1.setSpeed(95);
    motor1.run(FORWARD);
  motor2.setSpeed(95);
    motor2.run(FORWARD);
  motor3.setSpeed(50);
    motor3.run(FORWARD);
  motor4.setSpeed(50);
    motor4.run(FORWARD);
  }
void motorstop(){
  motor1.run(RELEASE);
  motor2.run(RELEASE);
  motor3.run(RELEASE);
  motor4.run(RELEASE);
  }
  


void loop() {
  Blynk.run();
  // put your main code here, to run repeatedly:
}

BLYNK_WRITE(V1){ 
int x = param[0].asInt(); 
int y = param[1].asInt();  

if(x==-1 && y==-1){             //BackWard and Left     
  motorLeftBack();
}else if(x==-1 && y==0){        //Left Turn 
  motorTurnLeft();
}else if(x==-1 && y==1){        //Forward and Left     
  motorLeftForward();
}else if(x==0 && y==-1){        //BackWard     
  motorBackward();
}else if(x==0 && y==0){        //Stay 
  motorstop();
}else if(x==0 && y==1){        //Forward 
  motorForward();
}else if(x==1 && y==-1){        //Backward and Right     
  motorRightBack();
}else if(x==1 && y==0){        //Right turn 
  motorTurnRight();
}else if(x==1 && y==1){        //Forward and Right 
  motorRightForward();
} 
}  

Not sure what you are trying to do or see… but the IDE serial monitor runs off of the programming serial port (Serial)… thus, why do you have?..

…As Serial2 is the 2nd auxiliary hardware serial port on the Mega (pins 16 & 17).

PS, change your Auth code now :stuck_out_tongue_winking_eye: and don’t show it to the forum, else someone else will try to drive your car :red_car:

1 Like

there is nothing to display exept “hello”
:wink:

LOL. thanks for respond.
I want to check the ESP connect to Wifi and Ping. Like this


And Serial2 is the Blynk print serial. Because i used L293D Shield, Serial already used.

oh. i want to see the ESP is connected to Wifi ang Ping.