Maybe you could do it with just an M42 in the G code. See [
reprap.org]
If you need to switch directions, it would be a bit more complicated--maybe you could hook a NAND gate to the pin and the extruder direction, and still get away with no firmware mods.