Getting digital input from a switch
Connect the switch to a digital in pin and the Vout (+3.3V). Create a DigitalIn object for the corresponding bit. The object will be 0 when not connected, 1 when the switch is closed.
To have the opposite behaviour, connect the switch to GND. Set the DigitalIn object mode() to PullUp. The object will now be 1 when not connected, 0 when the switch is closed.
Please log in to post comments.