导航

    • 登录
    • 搜索
    • 版块
    • 产品
    • 教程
    • 论坛
    • 淘宝
    1. 主页
    2. yd6i
    3. 楼层
    Y
    • 举报资料
    • 资料
    • 关注
    • 粉丝
    • 屏蔽
    • 帖子
    • 楼层
    • 最佳
    • 群组

    yd6i 发布的帖子

    • erron 110错误代码的原因是什么?

      0_1568354210942_6424a122-a8bf-4161-a16c-7bdbeaafce06-image.png
      import utime
      import ustruct

      At 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 = address

      self.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
      发布在 OpenMV Cam
      Y
      yd6i