Update variable while running if statement

@PaulS why pinmode on analog pins is not good idea?