Zwischenstand Motorenimplementierung

This commit is contained in:
Kevin Frantz
2017-04-15 00:42:23 +00:00
parent 88f0075735
commit 3df8ab165a
15 changed files with 132 additions and 6 deletions

19
test/pir2.py Normal file
View File

@@ -0,0 +1,19 @@
import RPi.GPIO as GPIO
import time
SENSOR_PIN = 19
GPIO.setmode(GPIO.BCM)
GPIO.setup(SENSOR_PIN, GPIO.IN)
try:
while True:
if GPIO.input(SENSOR_PIN):
print('Es gab eine Bewegung!')
else:
print('Es gab KEINE Bewegung!')
time.sleep(1)
except KeyboardInterrupt:
print("Beende...")
GPIO.cleanup()

25
test/ultraschall.py Normal file
View File

@@ -0,0 +1,25 @@
#!/usr/bin/python3
# Datei ultraschall.py
import time
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
trig = 5 # GPIO-Pin-Nummern
echo = 17
GPIO.setup(echo, GPIO.IN)
GPIO.setup(trig, GPIO.OUT)
while True:
GPIO.output(trig, True)
time.sleep(0.00001) # 10 Mikrosekunden
GPIO.output(trig, False)
while GPIO.input(echo) == 0:
pass
start = time.time()
while GPIO.input(echo) == 1:
pass
ende = time.time()
entfernung = ((ende - start) * 34300) / 2
print("Entfernung:", entfernung, "cm")
time.sleep(0.5)