Your flowchart in post#1 is not correct/incomplete
You clearly have some things happening once in setup()
you have 4 ifs in your loop(), one with an else. But you only have painted one if decision in your chart.
Start painting the loop top down and in the end you go back to the start of the "loop" section.
My guess is they were asked to write code and a flowchart of the code. The OP found the code and thought that's half the assignment now I just have to write the flowchart of this code I found.
Not having written the code, and not actually understanding the code he is stuck and asking us to complete his assignment for him.
Acceptable for describing a yes/no troubleshooting process, or the most trivial of programs, but terrible for even moderately complex structured algorithms, which is why languages like Algol have been used for so long.
Consider, how you would model a function call in a flowchart. Or a class.
By a double sided rectangle.
