Switches are the most common sensor around us. The Circuit Playground Express has three switches: two pushbuttons and one slide switch.

There are two large A and B buttons, connected to digital #4 (Left) and #5 (Right) each. These are unconnected when not pressed, and connected to 3.3V when pressed, so they read HIGH. Set the pins #4 and #5 to use an internal pull-down resistor when reading these pins so they will read LOW when not pressed.

There is a single slide switch near the center bottom of the Circuit Playground Express. It is connected to digital #7. The switch is unconnected when slid to the left and connected to ground when slid to the right. Set pin #7 to use an internal pull-up resistor so that the switch will read HIGH when slid to the left and LOW when slid to the right.

 

This is not an on-off switch, but you can use code to have this switch control how you want your project to behave.

Note that you need to use an internal pull-up for the slide switch, but an internal pull-down for the pushbuttons.

The following pages will show you how to quickly use these switches first in MakeCode then in CircuitPython.

This guide was first published on Jul 26, 2018. It was last updated on Jul 26, 2018.

This page (Using the Onboard Switches) was last updated on Jul 18, 2018.

Text editor powered by tinymce.