Hello! Anybody here could help me out when comparing a string with an internal address at the arduino side?
Using a dip-switch to define the address (0-15) - it's working getting INT (DEC) inside Arduino:
pinMode(9, INPUT_PULLUP); // Pin Dip-Switch(1)
pinMode(10, INPUT_PULLUP); // Pin Dip-Switch(2)
pinMode(11, INPUT_PULLUP); // Pin Dip-Switch(3)
pinMode(12, INPUT_PULLUP); // Pin Dip-Switch(4)
Serial.println("Boot OK");
address = byte((!digitalRead(9)*8)+(!digitalRead(10)*4)+(!digitalRead(11)*2)+!digitalRead(12));
Now I would like to compare a string received by another end ie: "T0x\r" where 'x' would be the internal address. I'm trying this but no working (sending from another side "T03\r)"
comrx = Serial.readStringUntil('\r');
Serial.println(comrx);
if(comrx == "T0" + (address)) ///// --> HERE IS THE COMPARISON THAT I'M TRYNG TO DO
{
delay(50);
digitalWrite(enablePin, HIGH);
delay(10);
Serial.println("Temp=");
delay(200);
digitalWrite(enablePin, LOW);
}
Thank yoU!!