I needed to connect to a serial device but I didn’t have a serial adapter for my computer. I took the photon and basically bridged Serial and Serial1 to basically form my own serial adapter.
int incoming1 = 0;
int incoming = 0;
void setup()
{
Serial.begin();
Serial1.begin(115200);
pinMode(D7, OUTPUT);
digitalWrite(D7, LOW);
}
// Rx Serial -> Tx Serial1
// Rx Serial1 -> Tx Serial
void loop()
{
digitalWrite(D7, LOW);
if (Serial1.available() > 0)
{
incoming1=Serial1.read();
Serial.write(incoming1);
}
if (Serial.available() > 0)
{
incoming=Serial.read();
Serial1.write(incoming);
digitalWrite(D7,HIGH);
}
}