I'm trying to connect two D1 Mini's together as a POC. There is a switch on one and a 7 segment display on the other
I have the pins setup from TX>RX and RX>TX
First ESP8266:
int SWITCH_PIN = D5;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
pinMode(SWITCH_PIN, INPUT);
pinMode(LED_BUILTIN, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
if(digitalRead(SWITCH_PIN) == HIGH)
{
Serial.println(1);
digitalWrite(LED_BUILTIN, HIGH);
}
else
{
Serial.println(0);
digitalWrite(LED_BUILTIN, LOW);
}
}
Second ESP8266:
#include "DigitLedDisplay.h"
DigitLedDisplay ld = DigitLedDisplay(D6, D5, D0);
void setup() {
Serial.begin(115200);
ld.setBright(10);
ld.setDigitLimit(8);
for (long i = 0; i < 100; i++) {
ld.printDigit(i);
delay(25);
}
}
void loop() {
delay(1000);
if(Serial.read() == 1)
{
ld.printDigit(11111111);
}
else if (Serial.read() == 0)
{
ld.printDigit(22222222);
}
else
{
ld.printDigit(33333333);
}
}
As far as I can tell the second ESP8266 isn't getting anything from the first. What am I doing wrong?
Thanks in advance for the help
Serial.println(1);
sends '1', not 1, so useSerial.read() == '1'