Under The Hood

The Circuit Playground has two push buttons. They are simple momentary buttons that effectively do the same thing as pressing the alligator clips together. But how are they integrated into the Circuit Playground? Do they deal with any of the issues we've talked about? Let's take a look.

Take a look at the schematic for the Circuit Playground. The circuit diagram for the buttons can be found in the upper left.

Let's just look at one button since they are both used in the same way. Here's a blow up of the part of the circuit diagram that matters. The thing above the label EVQQ is the actual button.

We don't have a button in our alligator clip setup, so let's remove it. Now we are left with this.

It may not look like it, but this is identical to the "pull down" version of our alligator clip setup. Here's the schematic showing where the various alligator clips are.

So the Circuit Playground deals with the floating input issue by using a pull down resistor. The same thing is done for both buttons. Righty-o.

Now, what about dealing with switch bounce? Any magic going on there? Well, let's take a look at the code for CircuitPlayground.leftButton() and see what's going on. Here it is (direct link to repo):

Download: file
boolean Adafruit_CircuitPlayground::leftButton(void) {
  return digitalRead(CPLAY_LEFTBUTTON);
}

Hmmmm. It just returns the value from digitalRead() for the input the button is attached to. Same as we've been doing with our alligator clips. That's it. Nothing else.

So, there is no debouncing being done by the Circuit Playground library. It is left up to the user (you) to incorporate this in their program somehow.

This guide was first published on Feb 26, 2017. It was last updated on Feb 26, 2017. This page (Under The Hood) was last updated on Jul 15, 2019.