Make high/low pin detection generic