Zum Inhalt springen

Relais Module 5V

Aus Computech CMS Wiki

-> 5V (Reihe 2, Pos 1), GND (Reihe 2, Pos 3) => aus Sicht des Stromanschluss -> GPIO 04 (Reihe 1, Pos 4)

import time
import RPi.GPIO as GPIO

GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
GPIO.setup(4, GPIO.OUT)

state = 1

while 1:

   if state:
        print "Set to High - Strom aus"
        GPIO.output(4, True)
        state = 0
   else:
        print "Set to Low - Strom an"
        GPIO.output(4, False)
        state = 1

   time.sleep(5)

print 'GPIO-Skript Ende'