Herunterladen Inhalt Inhalt Diese Seite drucken

SunFounder Da Vinci Kit Bedienungsanleitung Seite 289

Für den raspberry pi 4 modell b, 3 modell a +, 3 modell b +, 3 modell b, 2 modell b, 1 modell b +, 1 modell a +, zero w and zero
Inhaltsverzeichnis

Werbung

Für Python-Sprachbenutzer
Schritt 2: Verzeichnis wechseln.
cd
/home/pi/davinci-kit-for-raspberry-pi/python/
Schritt 3: Ausführen.
sudo python3 3.1.2_Welcome.py
Wenn der PIR-Sensor nach dem Ausführen der Kode jemanden erkennt, der vorbeikommt, öffnet sich die Tür automa-
tisch (vom Servo simuliert), schaltet die Anzeige ein und spielt die Türklingelmusik ab. Nachdem die Türklingelmusik
abgespielt wurde, schließt das System automatisch die Tür und schaltet die Anzeigelampe aus, um auf das nächste Mal
zu warten, wenn jemand vorbeikommt.
code
Bemerkung: Sie können den folgenden Code Ändern/Zurücksetzen/ Kopieren/Ausführen/Stoppen. Zuvor müssen
Sie jedoch zu einem Quellcodepfad wie davinci-kit-for-raspberry-pi\\python gehen.
import
RPi.GPIO
as
import
time
SERVO_MIN_PULSE
=
500
SERVO_MAX_PULSE
=
2500
ledPin
=
18
# define the ledPin
pirPin
=
17
# define the sensorPin
servoPin
=
22
# define the servoPin
buzPin
=
27
# define the buzzerpin
CL
=
[0, 131, 147, 165, 175, 196, 211, 248]
CM
=
[0, 262, 294, 330, 350, 393, 441, 495]
CH
=
[0, 525, 589, 661, 700, 786, 882, 990]
song
=
[
CH[5],CH[2],CM[6],CH[2],CH[3],CH[6],CH[3],CH[5],CH[3],CM[6],CH[2]
beat
=
[
1,1,1,1,1,2,1,1,1,1,1,]
def
setup():
global
p
global
Buzz
GPIO.setmode(GPIO.BCM)
GPIO.setup(ledPin, GPIO.OUT)
GPIO.setup(pirPin, GPIO.IN)
GPIO.setup(servoPin, GPIO.OUT)
GPIO.output(servoPin, GPIO.LOW)
GPIO.setup(buzPin, GPIO.OUT)
Buzz
=
GPIO.PWM(buzPin, 440)
Buzz.start(50)
1.9. 3 Erweiterung
GPIO
# Numbers GPIOs by physical location
# Set ledPin's mode is output
# Set sensorPin's mode is input
# Set servoPin's mode is output
# Set servoPin to low
# Set pins' mode is output
# 440 is initial frequency.
# Frequency of Low C notes
# Frequency of Middle C notes
# Frequency of High C notes
# Assign a global variable to replace GPIO.PWM
# Start Buzzer pin with 50% duty ration
SunFounder Da Vinci Kit
]
(Fortsetzung auf der nächsten Seite)
285

Werbung

Inhaltsverzeichnis
loading

Verwandte Produkte für SunFounder Da Vinci Kit

Diese Anleitung auch für:

Davinci-kit-for-raspberry-pi

Inhaltsverzeichnis