Converting a protein into a switch for biosensing and functional regulation