Thursday, 16 December 2021

string and char array compare

 String my = "this is red light i need space" , si, read1 , tem="t";

char text, tm="t";

int len;

void setup() {

  // put your setup code here, to run once:

  Serial.begin(9600);

  Serial.println();

  char buf[32] = "this is red light i need space";


  Serial.print("Char array: ");

  Serial.println(buf);

  String s = String(buf);

  Serial.print("String: ");

  Serial.println(s);

  if (my == s) {

    Serial.println("equal ");

  }

}

void loop() {

  if (Serial.available() > 0) {

    read1 = Serial.readString();

    text = read1.charAt(2);

      Serial.println(text);

     if(text==tm){Serial.println("temp");}

    len = read1.toInt();


    Serial.println(len);

    if (len == 25000) {

      Serial.println("equal");

    }

  }

}

No comments:

Post a Comment

Storing the long number(16bits / 32bits) in external flash of arduino or STM32 .

 #include <Wire.h> #define flashaddress 0x50 int liters = 10058 , add1=10 , add2,time1=55; // value of liters save in flash byte data ...