-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
35 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import RPi.GPIO as GPIO | ||
import time | ||
|
||
# Variable Counter definieren | ||
Counter = 0 | ||
|
||
# Variable zum debouncen | ||
Debounce = 0 | ||
|
||
# SoC als Pinreferenz waehlen | ||
GPIO.setmode(GPIO.BCM) | ||
|
||
# Pin 24 vom SoC als Input deklarieren und Pull-Down Widerstand aktivieren | ||
GPIO.setup(24, GPIO.IN, pull_up_down = GPIO.PUD_DOWN) | ||
|
||
# ISR | ||
def Interrupt(channel): | ||
# Zugriff auf globale Variablen | ||
global Counter | ||
|
||
# Counter um eins erhoehen und ausgeben | ||
Counter = Counter + 1 | ||
print "Counter " + str(Counter) | ||
|
||
# Interrupt Event hinzufuegen. Pin 24, auf steigende Flanke reagieren und ISR "Interrupt" deklarieren | ||
GPIO.add_event_detect(24, GPIO.RISING, callback = Interrupt, bouncetime = 200) | ||
|
||
# Endlosschleife | ||
while True: | ||
time.sleep(1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters