Пример #1
0
	def __init__(self, modulAddress, relayAddress):
		"""
		Initialize the object with the actual value reading from the hardware. 
		Initialize the actual value to 0, if there is an error during reading.
		
		Args:
			modulAddress (int): hexadecimal z.B. 0x20
			relayAddress (int): 1-4
		"""
		
		self._good = False
		self._actualValue = 0
		
		self._modul = gnublin.gnublin_module_relay()
		self._modul.setAddress(modulAddress)
		if relayAddress >= 1 and relayAddress <= 4:
			self._relayAddress = relayAddress
		else:
			raise InputError("relayAddress have to be between 1 and 4.")
		
		self.getValue()
Пример #2
0
import gnublin
import time

relay = gnublin.gnublin_module_relay()
relay.setAddress(0x22)

input = gnublin.gnublin_module_pca9555()
input.setAddress(0x20)
input.pinMode(8,"in")
input.pinMode(9,"in")
input.pinMode(10,"in")
input.pinMode(11,"in")

		
	

def forward():
	relay.switchPin(2,0)
	relay.switchPin(4,0)
	relay.switchPin(6,0)
	time.sleep(2)
	relay.switchPin(1,1)
	relay.switchPin(3,1)
	relay.switchPin(5,1)

def backwards():
	relay.switchPin(1,0)
        relay.switchPin(3,0)
        relay.switchPin(5,0)
	time.sleep(2)
        relay.switchPin(2,1)