On the lower left-hand portion of every Adafruit Circuit Playground Express, there is a small onboard speaker and class D amplifier. This allows you to make some pretty loud sounds! The amplifier is also connected to the true analog output on pin A0, which is marked with a wavy line symbol. You can turn off the speaker and only output through the pin if you like. For this tutorial, we are going to use the speaker and the capacitive touchpads to make a capacitive touch keyboard!

Transcript

Hi Steven, here from Core Electronics. Today we're going to talk about making a capacitive touch keyboard using Circuit Python and the Adafruit Circuit Playground Express.

The Adafruit Circuit Playground Express is a great board for this because it comes with 7 capacitive touch sensitive pads already made into the board. So, what we're doing here is we've got alligator clips from the capacitive sensitive touch pads to some strips of copper tape on this clipboard. So, they'll sense of touch and when you touch the paths the speaker emits a different note and lights light up a distinct colour. So, let's see how we did it.

If we look at the code in Circuit Python, this simple program it's basically just a big "if else if" statement. So, if we look at the top we have a slide switch off option, so that allows it to turn it off with the slide switch and then we have an "if else if" for each touchpad on the Circuit Playground Express. So, if A1 is touched then we print A1 in the serial monitor, we fill all the pixels to a colour and we play a tone and the tone is determined by hertz. So, 262 hertz are C I believe but it's easy to find which Hertz is which note. Then we have an "else if" for every other note in the scale and then down toward the bottom here we have something a little unique, which is the "else if" and "and not". So, if you're playing a scale, seven touchpads are just one note short of what you'd expect. So, if we do both last keys at the same time, then we get the higher note. So, we do this by having an "else-if", "and not". So, if A6 is touched but not A7 and we'll play A6 if, A7 is touched and not A6 then we'll play A7 and if they're both touched together then we'll play A8, which is just one note higher. The final else is to set all the pixels to off and the tones go off, otherwise they'll just keep playing and the lights will stay on then you'll have a ringing sustain on each note that you play.

So, another note about the capacitive touch keyboard is that capacitive touch pads are sensitive. So, we have alligator clips here with long wires, but whenever you have wires crossing there's potential for it to give false notes. So one way to do it is to just not touch the wires or move them around after the board's been powered up and maybe that'll work but I had to arrange the wires a little bit so you can touch too much, because you can see even just touching the wires themselves is enough to make a reading for capacitive touch and if the wires are touching each other than sometimes it can give a false note, so try to arrange your wires so they don't touch it all if possible maybe might need to take them to the table or something or find a find a good jumble where they were they don't touch.

So, if you'd like to learn about making a capacitive touch keyboard using MakeCode, I have a tutorial video coming up soon that'll walk you through that. If you have any other questions or comments, please hit us up on our forums and thanks for watching.

Feedback

Please continue if you would like to leave feedback for any of these topics:

  • Website features/issues
  • Content errors/improvements
  • Missing products/categories
  • Product assignments to categories
  • Search results relevance

For all other inquiries (orders status, stock levels, etc), please contact our support team for quick assistance.

Note: click continue and a draft email will be opened to edit. If you don't have an email client on your device, then send a message via the chat icon on the bottom left of our website.

Makers love reviews as much as you do, please follow this link to review the products you have purchased.