Wiring limit switches #24
-
|
Hello, I need some clarification on how to wire limit switches for the Gizmo board. The old VEX Cortex system allowed limit switches to be connected with two wires, as shown below: But I saw in a video on BESTedu that the instructor wired a limit switch with three wires: I apologize if this question has an obvious answer I missed; I just want to make sure I'm doing everything correctly as I learn this new system. Thank you! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 8 replies
-
|
That is a very reasonable question. You can use either wiring technique. If you use the two-wire technique, the switch will leave the port in a disconnected, or "floating", state. In this state nothing is driving the port either high or low, so the signal will effectively be random. You'll need to use the Gizmo's internal pull-up resistors, which are activated through software. The exact method will depend on which programming language you are using. In Arduino, when calling the pinMode(switchPin, INPUT_PULLUP);In CircuitPython, you can turn on the pull up resistor by setting the switch = digitalio.DigitalInOut(board.SLIDE_SWITCH)
# using switch_to_input function
switch.switch_to_input(pull=digitalio.Pull.UP)
# Or, using properties
switch.direction = digitalio.Directoin.INPUT
switch.pull = digitalio.Pull.UPUsing the three-wire configuration avoids the need for pull-up resistors because the switch itself drives the port in both the pressed and released states. |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.







That is a very reasonable question. You can use either wiring technique.
If you use the two-wire technique, the switch will leave the port in a disconnected, or "floating", state. In this state nothing is driving the port either high or low, so the signal will effectively be random. You'll need to use the Gizmo's internal pull-up resistors, which are activated through software. The exact method will depend on which programming language you are using.
In Arduino, when calling the
pinModefunction, set the mode toINPUT_PULLUP.pinMode(switchPin, INPUT_PULLUP);In CircuitPython, you can turn on the pull up resistor by setting the
pullproperty on the digitalio object. Example: