Herunterladen Inhalt Inhalt Diese Seite drucken

SunFounder Da Vinci Kit Bedienungsanleitung Seite 156

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

SunFounder Da Vinci Kit
# Set relayPin's mode to output,
# and initial level to High(3.3v)
GPIO.setup(relayPin, GPIO.OUT, initial=GPIO.HIGH)
# Define a main function for main process
def
main():
True:
while
print
('Relay
# Tick
GPIO.output(relayPin, GPIO.LOW)
time.sleep(1)
print
('...Relay
# Tock
GPIO.output(relayPin, GPIO.HIGH)
time.sleep(1)
# Define a destroy function for clean up everything after
# the script finished
def
destroy():
# Turn off LED
GPIO.output(relayPin, GPIO.HIGH)
# Release resource
GPIO.cleanup()
# If run this script directly, do:
if
__name__
==
'__main__':
setup()
try:
main()
# When 'Ctrl+C' is pressed, the child program
# destroy() will be
except
KeyboardInterrupt:
destroy()
Code Erklärung
GPIO.output(relayPin, GPIO.LOW)
Stellen Sie die Pins des Transistors auf einen niedrigen Niveau ein, damit das Relais geöffnet wird. Die LED leuchtet
nicht.
time.sleep(1)
1 Sekunde warten.
GPIO.output(relayPin, GPIO.HIGH)
Stellen Sie die Pins des Transistors auf einen niedrigen Niveau ein, um das Relais zu betätigen. Die LED leuchtet auf.
152
open...')
close')
executed.
(Fortsetzung der vorherigen Seite)
Kapitel 1. Über das Da Vinci Kit

Werbung

Inhaltsverzeichnis
loading

Verwandte Produkte für SunFounder Da Vinci Kit

Diese Anleitung auch für:

Davinci-kit-for-raspberry-pi

Inhaltsverzeichnis