Esempio n. 1
0
def relayBoardInit():
    status = relayExp.driverInit(relay_sw_addr)
    errorValue = True
    if status == 0:
        errorValue = False
    print_line('* relay driver init=[{}]'.format(status),
               debug=True,
               error=errorValue)

    bInit = relayExp.checkInit(relay_sw_addr)
    errorValue = True
    if bInit != 0:
        errorValue = False
    print_line('* relay driver checkInit=[{}]'.format(status),
               debug=True,
               error=errorValue)

    # force all relays to off
    relayExp.setAllChannels(relay_sw_addr, relay_off)
Esempio n. 2
0
# check initialization
# 	should return 1 since the Expansion was initialized above
ret = relayExp.checkInit(addr)
print "checking if initialized: ", ret
time.sleep(1)


# set channel 0 to on
ret = relayExp.setChannel(addr, 0, 1)
print "Result from relaySetChannel: ", ret
if ret != 0:
    exit()
time.sleep(2)

# set both channels to on
ret = relayExp.setAllChannels(addr, 1)
print "Result from relaySetAllChannels: ", ret
if ret != 0:
    exit()
time.sleep(2)

# set channel 0 to off
ret = relayExp.setChannel(addr, 0, 0)
print "Result from relaySetChannel: ", ret
if ret != 0:
    exit()
time.sleep(2)


print "Done"
Esempio n. 3
0
import time

from OmegaExpansion import AdcExp
from OmegaExpansion import relayExp

adc = AdcExp.AdcExp(address=0x48)

relayExp.driverInit(7)
relayExp.setAllChannels(7, 0)


def setRelay(num, state):
  relayExp.setChannel(defaultChannel, num, state)



print(dir(time))
GAIN = 2/3

adc.start_adc(3, gain=GAIN)

print('Reading ADC expansion channel 3 for 5 seconds')

while 1:

  value = adc.get_last_voltage()
  rPhoto = 5.0 / value * 1000 - 1000
  lux = 500/(rPhoto/1000)
  # print('Channel 3: %.02f V'%(lux))

time.sleep(1)

# set channel 0 to on
ret = relayExp.setChannel(addr, 0, 1)
print "Result from relaySetChannel: ", ret
if (ret != 0):
    exit()
time.sleep(2)

# read channel 0 value
value = relayExp.readChannel(addr, 0)
print "Channel 0 value: ", value
time.sleep(2)

# set both channels to on
ret = relayExp.setAllChannels(addr, 1)
print "Result from relaySetAllChannels: ", ret
if (ret != 0):
    exit()
time.sleep(2)

# set channel 0 to off
ret = relayExp.setChannel(addr, 0, 0)
print "Result from relaySetChannel: ", ret
if (ret != 0):
    exit()
time.sleep(2)

# read channel 0 value
value = relayExp.readChannel(addr, 0)
print "Channel 0 value: ", value
Esempio n. 5
0
def moveForward():
	relayExp.setAllChannels(addr, 1)
	time.sleep(0.5)
	relayExp.setAllChannels(addr, 0)
	return	
Esempio n. 6
0
 def setAllOn(self):
     relayExp.setAllChannels(self.defaultAddress, 1)