how is a transistor used as a switch