if (strcmp(readadress == adress) == 0) doesn't works

Hello friends.
I have this code

int adress; //adress from 0 to 99 is stored in EEPROM on cell n.1
int readadress; //adress read from serial

i need do this

if (readadress is the same like adress stored in EEPROM) {

do this;

}

I tried every combination but nothing works.
Do you have any ideas?

Thank you :slight_smile:

Please post the full sketch for your best attempt at doing this. If possible you should always post code directly in the forum thread as text using code tags (</> button on the toolbar). This will make it easy for anyone to look at it, which will increase the likelihood of you getting help. If the sketch is longer than the forum will allow then it’s ok to add it as an attachment. Don’t put your code in some external file service like dropbox, etc. We shouldn’t need to go to an external website just to help you. I do feel it’s reasonable to post a link to code hosted on GitHub or similar code hosting sites since that’s an platform specifically designed for this sort of thing

Please always do a Tools > Auto Format on your code before posting it. This will make it easier for you to spot bugs and make it easier for us to read. If you’re using the Arduino Web Editor then you will not have access to this useful tool. I recommend using the standard Arduino IDE instead.

      if (incomingByte=Serial.available()>0) {
      char byteIn = Serial.read();
      cmd[cmdIndex] = byteIn;

      if(byteIn == 125){         // when } is present, this means end of string
        //command finished

        cmd[cmdIndex] = '\0';           
        cmdIndex = 0;
        String mezi = cmd;
        String prikaz = mezi.substring(5,11);
        String odpal = mezi.substring(7,11);
        String readadress = mezi.substring (7,9);
        String adress = EEPROM.read(1);
        Serial.println(odpal);

         String adresazar[2] = adresa;

        if (mezi == adress +  "LEDON") { //ON
          digitalWrite(10, HIGH);
        }
          else if (mezi == adresa + "LEDOFF") { //OFF
           digitalWrite(10, HIGH);
        }

          else{
        }
        
      }
          else{
            if(cmdIndex++ >= MAX_CMD_LENGTH){
             cmdIndex = 0;
            }
         }
    }

Your thread title suggests that you are misusing strcmp(). The snippet you posted doesn't use strcmp() at all. Why did you post that snippet? Or choose that thread title?

Just what IS your problem?

You read one byte from EEPROM, piss away resources converting that byte to a String, and seem to expect that to match two characters read from the serial port. Is that reasonable?

I try to use strcmp, but doesn't works, for this time i try using == comparing

i need compare two types of data

i need compare String (from serial) with Int (from adress variable).

i use if (adresa.toInt() == adress){} and this work. bye