Arduino Robot with ESP-12E

Hi everyone! I’m now trying to connect the Arduino Robot with the ESP-12E.
When the ESP-12E receive data, the pin D0 of ESP-12E will become HIGH. The pin TKD1 of Arduino Robot is connected with the D0 of ESP-12E. Thus, when the D0 becomes HIGH, the TKD1 will becomes HIGH as well. Then, I write the coding and upload to the robot to let the robot moves forward when the TKDI is HIGH.

So the pin TKD1 has three holes: GND- DIGITAL- 5V. I connect the GND and the 5V with the GND and power of the ESP-12E respectively, the DIGITAL hole is connected to the pin D0 of ESP-12E.
After that, I tried to power the robot but it failed to work. The robot did not have changes in movement.

#include <ArduinoRobot.h>
#include <Wire.h>

#define sensor1 TKD1
#define sensor2 TKD3

void setup() {
  // initialize the robot
  Robot.begin();
  pinMode(sensor1,INPUT);
 
  pinMode(sensor2,INPUT);
 
}

void loop() {

   if(sensor1 == HIGH)
   { Robot.motorsWrite(255, 255);
     delay(300);
     Robot.motorsStop();
     delay(1000);
     }
  else if (sensor2 == HIGH)
    { Robot.motorsWrite(-255, -255);
     delay(300);
     Robot.motorsStop();
     delay(1000);
    }
    
}

Arduino Robot: Arduino Robot
ESP-12E: https://www.amazon.com/HiLetgo-Version-NodeMCU-Internet-Development/dp/B010O1G1ES/ref=cm_cr_arp_d_product_top?ie=UTF8

The coding is the code that I program to the robot.
Can anyone tell me which part of my project is wrong? Or the connections between the robot and the ESP are wrong? Thank you.

  if(sensor1 == HIGH) Did you miss something out?
A digitalRead, maybe?

AWOL:

   if(sensor1 == HIGH)

Did you miss something out?
A digitalRead, maybe?

#include <ArduinoRobot.h>
#include <Wire.h>

#define sensor1 TKD1
#define sensor2 TKD3

void setup() {
  // initialize the robot
  Robot.begin();
  pinMode(sensor1,INPUT);
  Robot.digitalWrite(sensor1,LOW);
  pinMode(sensor2,INPUT);
  Robot.digitalWrite(sensor2,LOW);
}

void loop() {

   Robot.digitalRead(sensor1);
   Robot.digitalRead(sensor2);

   if(sensor1 == HIGH)
   { Robot.motorsWrite(255, 255);
     delay(300);
     Robot.motorsStop();
     delay(1000);
     }
  else if (sensor2 == HIGH)
    { Robot.motorsWrite(-255, -255);
     delay(300);
     Robot.motorsStop();
     delay(1000);
    }
    
}

Something like this?
One more question, can I define the digital pins (TKD1 and TKD3) like this?

  if(sensor1 == HIGH) You seem to be missing something, like digitalRead.

AWOL:
  if(sensor1 == HIGH) You seem to be missing something, like digitalRead.

Yep, I've added the digitalRead into the code.

Ok, let's try a different approach.

What values did you give to "sensor1" and "sensor2"?

Is either value equal to HIGH (aka 1) ?

AWOL:
Ok, let’s try a different approach.

What values did you give to “sensor1” and “sensor2”?

Is either value equal to HIGH (aka 1) ?

Should I give them values? The two digital pins are connected with the two pins of the ESP and what I want is check the conditions of the two digital pins to see whether they are HIGH or LOW.
BTW, below is the coding after I edited. I deleted the defining part.

#include <ArduinoRobot.h>
#include <Wire.h>

void setup() {
  // initialize the robot
  Robot.begin();
  pinMode(TKD1,INPUT);
  Robot.digitalWrite(TKD1,LOW);
  pinMode(TKD3,INPUT);
  Robot.digitalWrite(TKD3,LOW);
}

void loop() {

  Robot.digitalRead(TKD1);
  Robot.digitalRead(TKD3);

   if(TKD1 == HIGH)
   { Robot.motorsWrite(255, 255);
     delay(300);
     Robot.motorsStop();
     delay(1000);
     }
  else if (TKD3 == HIGH)
    { Robot.motorsWrite(-255, -255);
     delay(300);
     Robot.motorsStop();
     delay(1000);
    }
    
}

And this coding is the coding that uploaded to the ESP.

#include <ESP8266WiFi.h>
#include<PubSubClient.h>

const char* ssid = "..."; // cannot be longer than 32 characters!
const char *pass = "...";

const char *mqtt_server = "...cloudmqtt.com";
const int mqtt_port = ...;
const char *mqttuser = "...";
const char *mqttpass = "...";

int LED1 = D0;
int LED2 = D1;


void callback(String topic,byte* payload,unsigned int length1){ 
    //Serial.print("message arrived[");
    //Serial.print(topic);
    //Serial.println("]");
String msgg;

for(int i=0;i<length1;i++){
    //Serial.print((char)payload[i]);
 msgg += (char)payload[i]; 
 
}
if(topic == "frown or surprise")
{
  if(msgg.substring(0,12) == "frown signal") //count from 0 and include the space
   { Serial.print("\n frown signal \n");
     digitalWrite(LED1,LOW);
     digitalWrite(LED2,HIGH);
   }
  else if (msgg.substring(0,15) == "surprise signal")
    {Serial.print("\n surprise signal \n");
     digitalWrite(LED2,LOW);
     digitalWrite(LED1,HIGH);
    }
}
}

WiFiClient espclient;
PubSubClient client(mqtt_server,19405,callback,espclient);

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

 pinMode(LED1,OUTPUT);

 pinMode(LED2,OUTPUT);
 

 WiFi.begin(ssid, pass);
 while (WiFi.status() != WL_CONNECTED) {
 delay(1000);
 Serial.println("Connecting to WiFi..");
 }
 Serial.println("Connected to the WiFi network");
 client.setServer(mqtt_server, mqtt_port);
 client.setCallback(callback);
 }
 
 void reconnect(){
 while (!client.connected()) {
 Serial.println("Connecting to MQTT…");
 if (client.connect("ESP8266Client", mqttuser, mqttpass )) {
 Serial.println("connected"); 
 client.subscribe("frown or surprise");
 } else {
 Serial.print("failed with state");
 Serial.print(client.state());
 delay(2000);
 }
 }
}

void loop() 
{
 if(!client.connected()){
 reconnect();
 }
 client.loop();

}

This is really difficult.

What is the numeric value of TKD1?
What is the numeric value of TKD3?

Is either of those values the same as HIGH (which is 1) ?

AWOL:
This is really difficult.

What is the numeric value of TKD1?
What is the numeric value of TKD3?

Is either of those values the same as HIGH (which is 1) ?

Yes.

Three questions, one answer.

That's not a good ratio.

AWOL:
Three questions, one answer.

That’s not a good ratio.

Well, actually I don’t get what you want. You asked me what values I give to sensor1 and sensor2. I want to give them the ‘1’ but I don’t know how to do it.

Yes, the two values are the same as HIGH (aka1).

*I’m sorry about that if I still misunderstood your question because English is not my first language.

Sin2:
Well, actually I don't get what you want.

If I asked you three questions, would you be happy with one answer?

I hope not.

I'll try a simpler approach.

What is the value of TKD1?
What is the value of TKD3?

Two questions.

Now, from you, two answers.
Go.

AWOL:
What is the value of TKD1?
What is the value of TKD3?

Two questions.

Now, from you, two answers.
Go.

Sorry AWOL. Before I answer your questions, how can I know the values of TKD1 and TKD3?

You could look them up, or you could print them.

I'm willing to place a bet that both of them do not have the value 1.

Which is why I'm asking you to use them as pin numbers, and read them

AWOL:
You could look them up, or you could print them.

I'm willing to place a bet that both of them do not have the value 1.

Which is why I'm asking you to use them as pin numbers, and read them

Sorry for my dumb question but how to look them up? The Arduino robot won't operate when it is connected with the laptop.

The Arduino Robot can now operate well according to the data received by the ESP.

Anyway, thank you for your help AMOL!