Thomas Angielsky
Published © GPL3+

Sensor Pushbutton with Darlington Pair

If in your projects mechanical buttons are inappropriate, perhaps a separate sensor button is the right choice.

BeginnerFull instructions provided1 hour1,236
Sensor Pushbutton with Darlington Pair

Things used in this project

Hardware components

General Purpose Transistor NPN
General Purpose Transistor NPN
×2
Resistor 10k ohm
Resistor 10k ohm
×1
Resistor 1k ohm
Resistor 1k ohm
×1
Resistor 100k ohm
Resistor 100k ohm
×1
Raspberry Pi 3 Model B
Raspberry Pi 3 Model B
×1

Story

Read more

Schematics

image

Code

Test-program for the sensor button

Python
It's only to test the signal
#!/usr/bin/python
# coding=utf-8

#(C)2018 https://tangielskyblog.wordpress.com

import time
import RPi.GPIO as GPIO

#Prellzeit in Sekunden
KEY_BOUNCE_TIME=2

#GPIO-Pin fr den Sensor-Taster
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:
        #Taste wird gedrckt, wg. Pull-Up Widerstand 10K beim Wert 0
        print("Sensor-Taste gedrckt")
        
        #Prelldauer fr Taster warten
        time.sleep(KEY_BOUNCE_TIME)    
    
GPIO.cleanup()
sys.exit()

Credits

Thomas Angielsky

Thomas Angielsky

18 projects • 36 followers
Mechanical engineer, maker, love woodwork, like Lazarus

Comments