You can control unused i/o pins using the M42 GCode command, see https://duet3d.dozuki.com/Wiki/Using_servos_and_controlling_unused_IO_pins. Does that help?