Схему "проекта" прикреплю ниже
Код:
#include <SoftwareSerial.h>
SoftwareSerial wifiSerial(2, 3);
#define RED 11
#define GRN 12
#define BLU 13
void setup()
{
pinMode(RED, OUTPUT);
pinMode(GRN, OUTPUT);
pinMode(BLU, OUTPUT);
Serial.begin(115200);
while (!Serial) {
;
}
}
void loop() {
digitalWrite(RED, LOW);
digitalWrite(GRN, LOW);
digitalWrite(BLU, LOW);
}
if (Serial.available() > 0) {
String message = readSerialMessage();
}
if (find(message, "debugEsp8266:")) { //Вот здесь выдает ошибку
String result = sendToWifi(message.substring(13, message.length()), responseTime, DEBUG);
if (find(result, "OK")) {
sendData("\nOK");
else
sendData("\nEr");
}
if (wifiSerial.available() > 0) {
String message = readWifiSerialMessage();
if (find(message, "esp8266:")) {
String result = sendToWifi(message.substring(8, message.length()), responseTime, DEBUG);
if (find(result, "OK"))
sendData("\n" + result);
else
sendData("\nErrRead"); //At command ERROR CODE for Failed Executing statement
} else if (find(message, "Red")) { //receives HELLO from wifi
sendData("\\nOh, red!")
digitalWrite(RED, HIGH)
delay(5000); //arduino says HI
} else if (find(message, "Green")) {
//turn on built in LED:
sendData("\\nOh, green!")
digitalWrite(GREEN, HIGH)
delay(5000);
} else if (find(message, "Blue")) {
//turn off built in LED:
sendData("\\nOn, blue!")
digitalWrite(BLUE, HIGH)
delay(5000);
}
else {
sendData("\nErrRead"); //Command ERROR CODE for UNABLE TO READ
}
delay(responseTime);
}
}
Вложения
-
541.1 KB Просмотры: 9