Why not duplicate the ADCIN and IF-THEN in your count to 30 loop, thus checking each time through the count loop?