Hello Forum.
String readedval = Serial.readStringUntil('\n');
if(readedval.length() != 0)
{
sold=s;
s = readedval;
}
I used this code to store 2 strings. but sold one always ands same as s
I cant find a way to fix this
Hello Forum.
String readedval = Serial.readStringUntil('\n');
if(readedval.length() != 0)
{
sold=s;
s = readedval;
}
I used this code to store 2 strings. but sold one always ands same as s
I cant find a way to fix this
Please post a complet example that compiles.
String s;
String sold;
void loop()
{
String readedval = Serial.readStringUntil('\n');
if(readedval.length() != 0)
{
sold=s;
s = readedval;
}
};
That 'complete example' does not compile here.
what....
Simple, setup() is missing ![]()
Further that code does not tell you that things are the same or not.
Well with this sold=s; sold will equal 2, always. If you do not want sold=s; then do this //sold=s;
then how do i gonna change the old value
not because the code is mixed with WinCe2.0 code
Where does Windows CE come in? You're asking questions on an Arduino forum so everyone will assume that you're using an Arduino. And Arduino code requires a setup() function.
So please provide full details of your project and why you think that you don't need setup() and how you can see with the provided code that something is wrong.
it was a typo
String s;
String sold;
void setup()
{
Serial.begin(9600);
}
void loop()
{
String readedval = Serial.readStringUntil('\n');
if(readedval.length() != 0)
{
sold=s;
s = readedval;
}
};
I'd put the new value into the old value after the new&old comparison has been done.
You have been asked this question at least twice. There is nothing in the code provided which prints or compares the Strings. Where is the input coming from?
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.