Marlin: Making any GPIO pin HIGH for a given time Is there any way Marlin Firmware supports G-code that can make a pin "high" and keep it at that state for a period of time specified? 

I have made a machine, which runs on Marlin Firmware, that is a mould forming tool, that would make a mould into a powder, then another tool would come over this mould and dispense some liquid in it. I have a custom GUI to move the tools to given coordinates, press a mould, position the second tool over the mould. 

For dispensing liquid I'm thinking about buying a diaphragm valve. I've downloaded the user manual for it. As per the documentation, when compressed air is given to valve it will lift diaphragm and will start dispensing. The amount of liquid it dispenses depends on the how long the valve is opened. So I'm thinking about using a relay to turn a solenoid valve ON and OFF to supply air to the valve. To turn the relay ON I need to make a certain GPIO pin "high". Is there any way I can do this in Marlin Firmware?
As explained in the comments by Tom, you can set any port directly from G-code using the M42 command. To set pin 22 "high", you need to call M42 P22 S255. There is no parameter to add time to the command, so you need to add that yourself using G4 (dwell or pause) to specify how long the printer needs to wait for the next instruction, e.g.:

M42 P22 S255 ; Activate solenoid/relay
G4 P2000     ; Dwell/pause for 2000 milliseconds (2 seconds)
M42 P22 S0   ; Deactivate solenoid/relay


As an alternative, you could use the existing fan if that fan is unused in your machine (or add an "extra fan" in the firmware and send the value 255 to that fan). To use the existing fan:

M106 S255 ; Activate solenoid/relay
G4 P2000  ; Dwell/pause for 2000 milliseconds (2 seconds)
M107      ; Deactivate solenoid/relay


How you add an extra fan is already described (for a specific RAMPS board) in this answer. However, the answer is valid for other boards as well, as long as you have exposed pins you have access to (or if you can solder directly to open pins), you can use the described technique. 

The G-code to activate the "extra fan" (solenoid) is M106 P1 S255 disabling would be M107 P1. Note that there is an option/parameter to add time (Bnnn Blip time - fan will be run at full PWM for this number of seconds when started from standstill) to the M106 command, but that is only implemented in RepRapFirmware. An alternative is to use G4 (dwell or pause) to specify how long the printer needs to wait for the next instruction (M107) is being parsed, e.g.:

M106 P1 S255 ; Activate solenoid/relay
G4 P2000     ; Dwell/pause for 2000 milliseconds (2 seconds)
M107 P1      ; Deactivate solenoid/relay