A relay is an electrically operated switch. Many relays use an electromagnet to mechanically operate a switch, but other operating…