Hello MiaoMiao,
The 'S' terminal on the port interface board is a 5V-tolerant digital input channel, pulled weakly high. A phototransistor is usually connected between 'S' and 'GND'. When IR light shines on the phototransistor, it creates a low resistance path to ground, pulling the line low. When something breaks the IR beam, the resulting low-->high transition is read by the state machine as a "PortXIn" event, where X is the port number. The next high --> low transition generates a "PortXOut" event.
You can create the same events with a pushbutton or switch. Simply connect the "S" terminal and the adjacent "GND" terminal on the port interface board to the switch terminals such that S is connected to GND when the switch is not pressed. Two things to be aware of: 1. If your switch is an SPDT type, one pole of the switch is connected to the output when the switch is at rest - you'll want to connect that pole to the "S" terminal. Connecting the other one will give you inverted logic. 2. You'll need to ensure that your state machine description can handle debouncing if the press duration is used as a behavioral contingency.
I hope this helps,
-Josh