Skip to content

Commit

Permalink
Adding "Interrupt.py"
Browse files Browse the repository at this point in the history
  • Loading branch information
Kampi committed Apr 12, 2013
1 parent e47dafe commit 14b2c18
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 5 deletions.
30 changes: 30 additions & 0 deletions Python/Raspberry Pi/Interrupt.py
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)
10 changes: 5 additions & 5 deletions Python/Raspberry Pi/README
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ And for UART (require python-dev):

$ sudo apt-get install python-serial

I work with RPi.GPIO 0.4.2a:
I work with RPi.GPIO 0.5.2a:

$ sudo wget https://pypi.python.org/packages/source/R/RPi.GPIO/RPi.GPIO-0.4.2a.tar.gz
$ sudo tar zxf RPi.GPIO/RPi.GPIO-0.4.2a.tar.gz
$ sudo cd RPi.GPIO/RPi.GPIO-0.4.2a
$ sudo tar zxf RPi.GPIO/RPi.GPIO-0.5.2a.tar.gz
$ sudo cd RPi.GPIO/RPi.GPIO-0.5.2a
$ sudo python setup.py install
$ sudo cd ..
$ sudo rm RPi.GPIO/RPi.GPIO-0.4.2a
$ sudo rm RPi.GPIO-0.4.2a.tar.gz
$ sudo rm RPi.GPIO/RPi.GPIO-05.2a
$ sudo rm RPi.GPIO-0.5.2a.tar.gz

And also python-smbus:

Expand Down

0 comments on commit 14b2c18

Please sign in to comment.