Arduino - 'setLocked' was not declared in this scope

As said, check your curlies. It looks like loop() is not 'closed' and hence setLocked is defined inside loop() which is what the compiler why the compiler can't find it.

As a side note, is there a reason why you clear the lcd 180 times in a row? I suspect that this indicates that the for loops inside loop are missing some '}'