Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

5
  • 2
    What line ending have you set in the Serial Monitor? My guess is, that the Serial Monitor sends a line ending after the actual data, which gets included by Serial.readString(), so that the string doesn't equal "on", but for example `"on\n". Commented Mar 1, 2023 at 8:49
  • @chrisl that was it... Serial.readStringUntil('\n') Commented Mar 1, 2023 at 8:52
  • 1
    Great, I've written a full answer to this question Commented Mar 1, 2023 at 9:01
  • 2
    @chrisl and all. this question is asked often. let's use this Q&A pair as canonical for future duplicates Commented Mar 1, 2023 at 9:54
  • I'm going to be cheeky and ask for some up votes from the community:) Commented Mar 3, 2023 at 2:21