The brain approch would work perfect for this because you won't need to do anything inside the G-code, It will just monitor the Z axis and activate/deactivate the pin at the correct height.

While watching I could hear an air solenoid firing then read that he use's a pnuematic dispenser connected to a 555 timer and 3 way valve to control over dispense. The Brain and Mach could be made to act as the timer but how would you control over dispense.?