erron 110错误代码的原因是什么?
-
import utime
import ustructAt reset, the device's ports are inputs with a high value resistor pull-ups to VDD
If relays turning on during power up are a problem. Add a pull down resistor to each
relay transistor base.
CmdBys={
'IN_P0':0x00, #Read Input port0
'IN_P1':0x01, #Read Input port1
'OUT_P0':0x02, #Write Output port0
'OUT_P1':0x03, #Write Output port1
'INV_P0':0x04, #Input Port Polarity Inversion port0/1 if B11111111 is
'INV_P1':0x05, #written input polarity is inverted
'CONFIG_P0':0x06,#Configuration port0/1 configures the direction of the
'CONFIG_P1':0x07 #I/O pins, 0 is output 1 is input
}
class PCA9555:
#with no jumpers the full address is 1 0 0 1 1 1
#1 0 0 A2 A1 A0 0x27 is the default address for the DFR0013 board with no jumpers.
#0x20 is address for the DFR0013 board with all jumpers.
def init(self, i2c, address=0x20):
self.i2c = i2c
self.address = addressself.reset()
def _write(self, address, value): #这里的address为器件内部地址 self.i2c.writeto_mem(self.address, address, bytearray([value])) def _read(self, address): return self.i2c.readfrom_mem(self.address, address, 1)[0]
def reset(self):
self._write(0x00, 0x00) # Mode1
def Output(self, Outvalue=None): #高八位给端口1,低八位给端口0 self._write(CmdBys['CONFIG_P0'], 0x00) self._write(CmdBys['CONFIG_P1'], 0x00) if Outvalue is None: self._write(CmdBys['OUT_P0'], 0x00) self._write(CmdBys['OUT_P1'], 0x00) else: value0=Outvalue&0xff value1=(Outvalue>>8)&0xff self._write(CmdBys['OUT_P0'], value0) self._write(CmdBys['OUT_P1'], value1) def Input(self): self._write(CmdBys['CONFIG_P0'], 0xff) value0=self._read(CmdBys['IN_P0']) self._write(CmdBys['CONFIG_P0'], 0xff) value1=self._read(CmdBys['IN_P1']) Invalue=(value1<<8)|value0 return Invalue