How To Use A Relay With A Raspberry Pi

How To Use A Relay With A Raspberry Pi

By admin ·
1

The video

The following video will show you how to wire up the relay to your Raspberry Pi.

2

The test script

Here’s a copy of the test script used in the video:

#!/usr/bin/env python

import time

import RPi.GPIO as GPIO


GPIO.setmode(GPIO.BCM)
GPIO.setup(17, GPIO.OUT)
GPIO.output(17, GPIO.LOW)

time.sleep(0.25)

GPIO.output(17, GPIO.HIGH)
GPIO.cleanup()

To run the script, simply copy the code above to a file on your Raspberry Pi called test-relay.py (or whatever you want). And then run the script using:

python test-relay.py