Skip to content

Instantly share code, notes, and snippets.

@sukso96100
Created June 18, 2015 15:56
Show Gist options
  • Save sukso96100/77c4320ab360268c5139 to your computer and use it in GitHub Desktop.
Save sukso96100/77c4320ab360268c5139 to your computer and use it in GitHub Desktop.
Raspberry Pi Model B+ 8 Channel Relay Module Test
import RPi.GPIO as GPIO
import time
print "Ready?"
time.sleep(5)
print "Setting GPIO Mode as BCM"
GPIO.setmode(GPIO.BCM)
print "Setting Up GPIO from 2 to 9"
GPIO.setup(2, GPIO.OUT)
GPIO.setup(3, GPIO.OUT)
GPIO.setup(4, GPIO.OUT)
GPIO.setup(5, GPIO.OUT)
GPIO.setup(6, GPIO.OUT)
GPIO.setup(7, GPIO.OUT)
GPIO.setup(8, GPIO.OUT)
GPIO.setup(9, GPIO.OUT)
print "Testing Relay Module Control with GPIO"
for i in range(2, 10):
GPIO.output(i,True)
time.sleep(1)
print("GPIO %d is True" % (i))
for i in range(2, 10):
GPIO.output(i,False)
time.sleep(1)
print("GPIO %d is False" % (i))
print "Done Testing. Cleaning Up GPIO"
GPIO.cleanup()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment