connecting this relay to a pin

Yes, but you should wire a diode across the coil terminals in reverse bias to suppress transients when de-energizing.

Lefty