matching a string
in
Integration and Hardware
•
1 year ago
I am getting a value from arduino that is either 0 or 1 which is a string and I am trying match it, but for some reason .equals and == both seem to fail to catch the comparison. Here is what I have:
- void serialEvent (Serial myPort) {
- String isLukaszHome = myPort.readStringUntil('\n');
- println("isLukaszHome: "+ isLukaszHome);
- if(isLukaszHome.equals("0")){
- sendTweet("Lukasz left at: "+hour()+":"+minute());
- println("left");
- }
- }
isLukaszHome clearly returns a 0 at times ("isLukaszHome: 0" in the debug window), but it doesn't seem to match ever.
the isLukaszHome is coming from Serial communication from arduino if that helps at all...?
ideally I'd like something as clean as in JS where you could say...
- if(isLukaszHome){
- sendTweet("Lukasz is home at: "+hour()+":"+minute());
- }
Any ideas?
1