If in your projects mechanical buttons are inappropriate: the shape does not fit, the installation space is missing or the color is not good, perhaps a separate sensor button is the right choice.
A sensor button does not respond by the mechanical contact between two conductors or by a magnetic element as in a reed contact. It responds with a switching signal to the touch of its sensor surfaces. That makes eg many applications – such as use in clothing – possible in which a normal pushbutton is not suitable.
Function of sensor button
The sensor surfaces consist only of a broken line. In the simplest case, these can be two bare wires. In the case of your washing machine or TV, it’s more conductive, nicely shaped surfaces. This makes an extremely flat design possible.
Upon contact with your hand or finger, the electronics will respond and output a tactile signal. A small current flows through your body and closes the circuit for the signal.
The circuit is based on a Darlington pair. By connecting the two transistors (eg a BC547C) a high current gain is achieved. As a result, the very small current through your finger is enough for the base of transitor T1 to go through.
To prevent the circuit from becoming too sensitive, resistor R3 is installed. You can experiment with it a little and use other values or no resistor.
As long as you now put a finger on the contact, the transistors go through. Take your finger away again and it turns off. This signal can be used as an input signal for a microcontroller as a touch signal.
Test setup
For a test, it is best to take a breadboard and build the circuit. Any type of microcontroller with GPIO contacts can be considered for the evaluation.
I use in this example a Raspberry Pi. As a supply voltage suitable for the switching signal of the Pi 3.3 V are used. The circuit works just as well for an Arduino or ESP8266 with 5 V.
For the visualization, we also install a LED with a suitable resistor. Here you must consider the supply voltage. That’s about 100 ohms at 3.3V and at 5V about 220 ohms.
A test program for the RasPi could look like this with Python:
import time import RPi.GPIO as GPIO #Bounce time in seconds KEY_BOUNCE_TIME=2 #GPIO-Pin of the sensor button PinButton=4 GPIO.setwarnings(False) GPIO.setmode(GPIO.BCM) GPIO.setup(PinButton,GPIO.IN) while True: time.sleep(0.1) print(GPIO.input(PinButton)) if GPIO.input(PinButton)==0: #Button is pressed; it' 0 because of the pull-up resistor print("Sensor button ist pressed") #Wait bounce time time.sleep(KEY_BOUNCE_TIME) GPIO.cleanup() sys.exit()
Contact types
There are many ways to create the contacts types. And it probably depends on the demands of your project. Here your ingenuity is in demand. As an inspiration, here are a few suggestions for you.
a) Parallel bare wires
b) Washer and nail head
c) 2 nail heads next to each other
d) Package clips or sample bag clips
e) Metal rivets in fabric
With the sensor button you now have a solution at hand, if a classic button is not the right choice. As you have seen, all you need is a few electronic components, a little source code, and imagination to make the contact surfaces.
Links
Interesting facts about the Darlington circuit can be found on wikipedia.org:
https://en.wikipedia.org/wiki/Darlington_transistor
I used the sensor button with my mediaplayer to turn on and off the Raspberry Pi touch display: On/Off switch for the Raspberry Pi touch display
Pingback: Sensor-Taster mit Darlington Schaltung – Mein Techblog
Pingback: Sensor-Taster mit Darlington Schaltung - Tech+Code