Often there is a need to use a switch/button as an input to a MMBasic project. This is easy to implement as an input can be specified with an internal pullup resistor of about 100 kohm. This resistor is internal to the microcontroller and (when enabled) will be connect between the input pin and the 3.3V supply. This means that the switch can be connected between the ground and the input pin. When the switch/button is open the input will be high (pulled up by the internal resistor) and when closed the input will be zero.
To specify a pullup resistor you use SETPIN as follows:
SETPIN pin, DIN, PULLUP
When you use a switch/button you will also have to consider the issue of contact bounce. This is when the switch contacts mechanically touch and then bounce apart momentarily due to the momentum of the mechanical assembly. Because the MMBasic runs very fast a program could see this as a secession of quick button presses rather than a single press.
You could check for this in your program, for example by checking 100mS after the first contact closure to confirm that the contacts are indeed closed.
A simpler solution, but one involving a small amount of hardware, is to connect a 100nF capacitor across the switch contacts. This capacitor in association with the internal pullup resistor will average out any rapid contact bounce so that the program will see a smooth transition from on to off and vice versa.