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 how to make a capacitive touch keyboard using MakeCode and the circuit playground Express.

The Circuit Playground Express is perfect for capacitive touch projects because it has seven capacitive touch sensitive paths already built into the board and it doesn't take any special programming in order to utilize them.

So, one of the fun things about a capacitive touch keyboard is that you can use really anything for your keys. I've chosen to use strips of copper paper but you could use wires stuck into fruit or glasses of water or tools you have laying around and really anything or just touch the pads directly on the board, so let's take a look at our end result.

So, for each note we have a different key and every time you press a key, the lights in the ring light up a different colour, so something to note about making capacitive touch keyboard is that it takes very little to activate the capacitive touch pad, so just touching the wires that are going to the different copper strips is enough to activate them on the board and sometimes just the wires touching each other can be enough, so moving the board around once it's powered up might lead to some false activations and you may need to organize your wires in a way where they don't touch.

I've gotten lucky with this random jumble right here that they all seem to not be activating but everybody's is a little different. If we take a look at the code in MakeCode that I used to make this program, we have within our forever loop I've set the brightness of the lights and turned the volume down a little bit because it can be quite loud and then everything else is just put into an “if” and “else if” statement and something I want to note about how I made this is if you have an if/else block there's only two fields here, but if you hit the plus at the bottom then it lets you add as many fields as you want and that's what we've done in order to make this program.

So we have an “if” and our input is a press from pin A1 and then we've set a music tone to ring, so it continues to play while the conditions met and you can choose a different note from the keyboard here, to set them to whatever you like and then we have a light command to set all the pixels to whatever colour we choose as well for each key and then an important part to note, is down at the bottom the “else” so if none of these conditions are met then at the “else” will stop all sounds and will turn all the pixels off because we don't want the sound to continuously ring and we don't want the lights to stay on when nothing's being touched, and you can see that we can try it out on our virtual board as well and something to consider adding into your program is a slide switch command to off.

So if the slide switch isn't activated say that that none of this is run because then you can have kind of a kind of an on/off without unplugging it but it'll still technically be on and you can also do tones that if you touch multiple points at once it plays a completely different tone. So, it allows you to have a greater variety of notes from the same capacitive touch pads and it's something to consider when you're working on the project yourself.

So, thanks for watching if you want to learn more about the Adafruit circuit playground Express or working with mate code check out our tutorials section or look at our other videos and if you have any questions or comments hit up our forums.

Comments


Loading...
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.