Using the generic on/off server model to write D1 pin 0/1 instead of BSP_LED

I would like to set or clear a digital pin when the button is pressed. 

I seen to have achieved this with the on-board button but it doesn't work with a mesh switch. 

I need help with a sample code.

#define ONOFF_SERVER_0_LED          (BSP_LED_0) 
#define TRIGGER_PIN          (39) 


 nrf_gpio_cfg_output (39);