KS0212 keyestudio RPI 4-channel Relay Shield

Raspberry projects

KS0212 keyestudio RPI 4-channel Relay Shield

Messaggio da leggereda root » 10/01/2019, 11:59

Immagine

Immagine

Codice: Seleziona tutto
#!/usr/bin/python
# KS0212 keyestudio RPI 4-channel Relay Shield
# http://wiki.keyestudio.com/index.php/KS0212_keyestudio_RPI_4-channel_Relay_Shield

import RPi.GPIO as GPIO
import time

GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)

# init list with pin numbers

pinList = [4, 22, 6, 26]

# loop through pins and set mode default state is 'low'

for i in pinList:
    GPIO.setup(i, GPIO.OUT)

# active each relay for 2 seconds with 2 second delay between each activation
for i in pinList:
    GPIO.output(i, GPIO.HIGH)
    print i, " on"
    time.sleep(2)
    GPIO.output(i, GPIO.LOW)
    print i, " off"
    time.sleep(2)
# Reset GPIO settings
GPIO.cleanup()
Maurizio
Avatar utente
root
Amministratore
 
Messaggi: 429
Iscritto il: 10/04/2012, 10:55
Località: Turin

Torna a Raspberry

Chi c’è in linea

Visitano il forum: Nessuno e 1 ospite

cron