OpenSprinkler Forums Hardware Questions OpenSprinkler Pi (OSPi) Help with OpenSprinkler PI Re: Re: Help with OpenSprinkler PI

#23506

bstienst
Member

Well I got another Rasberry Pi from a friend, and I get the same results.

I tested each the pins with a MultiMeter using this script to toggle the output:

#!/usr/bin/env python

import time
import os
import RPi.GPIO as GPIO
import atexit

# GPIO PIN DEFINES

pin_sr_clk = 4
pin_sr_noe = 17
pin_sr_dat = 21 # NOTE: if you have a RPi rev.2, need to change this to 27
pin_sr_lat = 22

def run():
GPIO.cleanup()
# setup GPIO pins to interface with shift register

GPIO.setmode(GPIO.BCM)
GPIO.setup(pin_sr_clk, GPIO.OUT)
GPIO.setup(pin_sr_noe, GPIO.OUT)
GPIO.setup(pin_sr_dat, GPIO.OUT)
GPIO.setup(pin_sr_lat, GPIO.OUT)


# TEST NOE = PIN 17
# while True:
# print "NOE(17) set to 0"
# GPIO.output(pin_sr_noe, False)
# time.sleep(2)
# print "NOE(17) set to 1"
# GPIO.output(pin_sr_noe, True)
# time.sleep(2)

# TEST CLK = PIN 4
# while True:
# print "CLK(4) set to 0"
# GPIO.output(pin_sr_clk, False)
# time.sleep(2)
# print "CLK(4) set to 1"
# GPIO.output(pin_sr_clk, True)
# time.sleep(2)

# TEST DAT = PIN 21
while True:
print "DAT(21) set to 0"
GPIO.output(pin_sr_dat, False)
time.sleep(2)
print "DAT(21) set to 1"
GPIO.output(pin_sr_dat, True)
time.sleep(2)

# TEST LAT = PIN 22
# while True:
# print "LAT(22) set to 0"
# GPIO.output(pin_sr_lat, False)
# time.sleep(2)
# print "LAT(22) set to 1"
# GPIO.output(pin_sr_lat, True)
# time.sleep(2)

def progexit():
GPIO.cleanup()

if __name__ == '__main__':
atexit.register(progexit)
run()

by uncommenting approriate section to see if the pin changes from 1 -> 0 ->1 and they all work as expected. I know its a bit crud, but effective.

I did not have to use 27 but I had to use 21 to get the DAT pin to work. I’m pretty sure I have a rev B board, so I’m a bit confused about that.