mirror of
https://github.com/kevinveenbirkenbach/erinaco.git
synced 2024-11-23 14:31:04 +01:00
GPIO-Mapping angepasst und allgemeine Aenderungen
This commit is contained in:
parent
0a8b3577bb
commit
88f0075735
30
gpio_mapping.py
Normal file
30
gpio_mapping.py
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
import RPi.GPIO as GPIO
|
||||||
|
GPIO.setmode(GPIO.BCM);
|
||||||
|
|
||||||
|
def checkInput(pin,name):
|
||||||
|
GPIO.setup(pin, GPIO.IN);
|
||||||
|
print("Pin {0}; Value {1}; {2}; ".format(pin,GPIO.input(pin),name));
|
||||||
|
def output(pin,name):
|
||||||
|
print("Pin {0}; Name {1};".format(pin,name));
|
||||||
|
print('--- Allgemeine Sensoren ---')
|
||||||
|
checkInput(19,"PIR")
|
||||||
|
checkInput(26,"DHT11")
|
||||||
|
print('--- Linetrackingsensoren (Erster Sensor-Fahrtrichtung-Rechts) ---');
|
||||||
|
checkInput(21,"IR-LT-1")
|
||||||
|
checkInput(20,"IR-LT-2")
|
||||||
|
checkInput(16,"IR-LT-3")
|
||||||
|
checkInput(12,"IR-LT-4")
|
||||||
|
print('--- Ultraschall-Abstanssensoren (Erster Sensor-Fahrtrichtung-Rechts) ---');
|
||||||
|
output(13,"UA-1-TRIGGER")
|
||||||
|
checkInput(22,"UA-1-ECHO")
|
||||||
|
output(6,"UA-2-TRIGGER")
|
||||||
|
checkInput(27,"UA-2-IN")
|
||||||
|
output(5,"UA-3-TRIGGER")
|
||||||
|
checkInput(17,"UA-3-IN")
|
||||||
|
print('--- Motorenbelegung ---');
|
||||||
|
output(18,"A-1A") #Grau
|
||||||
|
output(23,"A-1B") #Weiss
|
||||||
|
output(24,"B-1A") #Blau
|
||||||
|
output(25,"B-1B") #Lila
|
||||||
|
GPIO.cleanup();
|
||||||
|
|
@ -1,9 +0,0 @@
|
|||||||
import RPi.GPIO as GPIO
|
|
||||||
GPIO.setmode(GPIO.BCM);
|
|
||||||
pin=0;
|
|
||||||
while pin<=40:
|
|
||||||
GPIO.setup(pin, GPIO.IN);
|
|
||||||
print("Pin {0}; Value {1};".format(pin,GPIO.input(pin)));
|
|
||||||
pin += 1;
|
|
||||||
GPIO.cleanup();
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
|||||||
import RPi.GPIO as GPIO
|
import RPi.GPIO as GPIO
|
||||||
import time
|
import time
|
||||||
|
|
||||||
SENSOR_PIN = 22
|
SENSOR_PIN = 19
|
||||||
|
|
||||||
GPIO.setmode(GPIO.BCM)
|
GPIO.setmode(GPIO.BCM)
|
||||||
GPIO.setup(SENSOR_PIN, GPIO.IN)
|
GPIO.setup(SENSOR_PIN, GPIO.IN)
|
||||||
@ -14,7 +14,7 @@ try:
|
|||||||
GPIO.add_event_detect(SENSOR_PIN , GPIO.RISING,
|
GPIO.add_event_detect(SENSOR_PIN , GPIO.RISING,
|
||||||
callback=mein_callback)
|
callback=mein_callback)
|
||||||
while True:
|
while True:
|
||||||
time.sleep(100)
|
time.sleep(1)
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
print("Beende...")
|
print("Beende...")
|
||||||
GPIO.cleanup()
|
GPIO.cleanup()
|
||||||
|
Loading…
Reference in New Issue
Block a user