This circuit is designed to switch an external load with complete isolation from the control circuitry.

The microcontroller drives a transistor (Q1) which in turn powers the relay (RLY1).

A diode (D1) is in place to suppress transients from the relay coil.