ຮັບສົ່ງຂໍ້ມູນຫາກັນລະຫວ່າງ Arduino to Nodemuc Esp8266 ຜ່ານ Serial

Arduino ໃຊ້ Pin 10 ແລະ Pin 11

Nodemcu Esp8266 ໃຊ້ Pin D6 ແລະ Pin D5

ຕົວຢ່າງ Code ສົ່ງຄ່າຈາກ Arduino ໄປຫາ NodeMCU

int a = 13;
int b = 25;
#include <SoftwareSerial.h>
SoftwareSerial chat(10, 11); // RX, TX
int i;
void setup() {
Serial.begin(9600);
chat.begin(4800);
}
void loop() {
if (chat.readString()){
// chat.print(1);
if(chat.readString()== “Question1”){
chat.print(a);
}
if(chat.readString()== “Question2”){
chat.print(b);
}
Serial.print(“Send = “);
Serial.println(i);
}
i++;
delay(1000);
}

ຕົວຢ່າງ Code ສົ່ງຄ່າຈາກ NodeMCU ໄປຫາ Arduino

#include <SoftwareSerial.h>
SoftwareSerial chat(D5, D6); // RX, TX
String a;
void setup() {
Serial.begin(9600);
chat.begin(4800);
delay(10);
}
void loop() {
Serial.println(“Please wait Serial..”);
while (a == “”) {
chat.print(“Question1”);
a = chat.readString();
delay(100);
Serial.print(“.”);
}
}

ທີມາ: http://www.9arduino.com

ຂຽນໂດຍ: ຄຳໄພ ຄຸນນະວົງສາ

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.