In this recipe, you will learn how to define a class that can help you use handle touch events on a particular touchpad. When you create an instance of this class, you specify the pad name and a callback function that will be called each time a touch event starts and ends. We can use this class as a building block to have a callback called for each of the four touchpads that will be connected to bananas. You can use this style of code in your own projects, whenever you want to handle a variety of events with a set of callback functions.
Creating a class to react to touch events
Getting ready
You will need access to the REPL on Circuit Playground Express to run the code presented in this recipe.