Here is a good introduction to capacitive sensing. Read through it to see possible uses and helpful tips for making your own.
Here is my simplified and clarified revision of the example code: https://gist.github.com/ericjforman/8fd70b69a1751588aee1f9fcffa7cd42
Don’t forget to install the CapacitiveSensor library from the Arduino IDE:
- Go to menu Sketch / Include Library / Manage Libraries, then search for “capacitiveSensor”
- Select library by “Paul Badger, Paul Stoffregen,” select latest version, click Install