iBeacon detector [SOLVED]

This is the only place in your code where you set pin 2 LOW, BUT if you look at the logic that proceeds it... the code can never get to this point. foundBeacon needs to be true to get passed the first "if" and false to get passed the second "if"... so not possible.