I had a lamp that works using capacitive touch as a switch and it gave me the idea.
When I worked with the microcontroller and there was some error or bad connection in hardware circuit I noticed that the microcontroller showed irregular behavior during touching it when reading zeros and ones inputs to the GPIOs.
Here's how I got the idea of using the microcontroller as a touch sensor.
I've tried to make the circuit and code it myself but I had unreliable results. I thought that the idea was wrong and would never work.
When I searched for it online I found a video showing how it worked so good. I wanted to share it with you.
I found it on this blog:
I'll try it and will make some modification to it.
I'll also add a photo of my own circuit.
Here is the basic C code that does the job
unsigned int avg;
unsigned int current=0;
unsigned int thresh=29;
unsigned int trials=10;
Here is a video from the maker
The idea is very simple and straight forward.
The code can be applied to any microcontroller with this C language code.
Thank you for reading.