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*

6
  • You need to select your code and tap the {} (code formatting) button. I did it for you. Commented May 12, 2019 at 19:29
  • 3
    Of course it's undeclared. The variable is in setup. It's not in loop. Commented May 12, 2019 at 19:30
  • 1
    Because the variable is only valid, where it is declared, to use the official term: it's scope. When the program moves out of the scope of this variable, it will get thrown away and be no longer available. You can declare it in global scope, meaning outside of any function Commented May 12, 2019 at 19:32
  • This is more a question about C/C++, not about Arduino Commented May 12, 2019 at 19:33
  • @chrisl true, but the OP doesn't know enough to know where to ask the question. We all have to start somewhere. I just wish people would do some self-study before running to the internet looking for somebody else to answer their questions for them. Commented May 12, 2019 at 19:35