In my code I want to declare a boolean variable "found" to be equal to false which along the functions may become true, but after the loop is done I want it to be set to false again. I tried putting it in the void loop() function, but it can't be read from the other functions. I also tried making it global inside one of my other functions so that it resets every time they are called, but without success. The function read() is in the loop(). Anyone has an idea?
Thanks in advance!
void read_() {
boolean found = false;
((calling some functions that need to access "found" and could change "found" to true;))
if(found == true){
...
}
}// after everything is terminated, "found" needs to be reset to false
lordjimen:
I also tried making it global inside one of my other functions so that it resets every time they are called, but without success.
That doesn't make sense. If you want a variable to be global, you need to declare it outside of and function. If you declare it inside a function then it is local to that function, not global.
pert:
That doesn't make sense. If you want a variable to be global, you need to declare it outside of and function. If you declare it inside a function then it is local to that function, not global.
Yes, but if I make it global, then it stays changed and is not reset to false as I would like it to be.