Now we're starting to get to the sensors built into the Circuit Playground. These are parts that are normally not included on an Arduino-like board. They are yours to play with and use as you travel on the path of learning!
There are two momentary pushbuttons, you can use these in any of your projects to change modes, indicate when to start or stop a sketch, modify behavior, really anything!
- The Left button is connected to digital pin #4
- The Right button is connected to digital pin #19
Both have 10KΩ pull-down resistors. That means that when the button is pressed the value read off those pins will be 'high'. You'll learn more about that later, but its here for your reference
The slide switch is near the center, right above the JST Battery Jack. There's a little nub you can slide left or right. This switch is connected to digital pin #21. When switched to the left, the value reading is 'high' (thus the + symbol) and when switched right, the value read is 'low' (- symbol).
You can call
CircuitPlayground.slideSwitch() to tell you which way the switch is flipped. It will return true if the switch is to the left (+ side) and false if the switch is to the right (- side)
leftButton and rightButton
You can ask if the buttons are pressed by calling
CircuitPlayground.rightButton(). They will return true if and only if the button in question is being pressed right when the function is called.