项目作者: martin96

项目描述 :
Android Things driver for the PiFace Digital 2
高级语言: Java
项目地址: git://github.com/martin96/androidthings-PiFaceDigital2-driver.git


androidthings-PiFaceDigital2-driver

This repository contains the Android Things driver to control the MCP23S17 chip on the PiFace Digital 2.

Only tested with a Raspberry Pi 3, but shouldn’t be hard to adapt for other boards too.

PiFace Digital 2

Image of PiFace Digital 2

PiFace Digital has eight inputs, eight outputs, eight LED’s, two relays and four switches.

Using

To use it in your Android Things project:

  1. PiFaceDigital2 mPiFaceDigital2 = PiFaceDigital2.create(SPI_DEVICE_NAME);
  2. // The LED’s are connected in parallel to each of the outputs
  3. // This means that when you set output pin 4 high, LED 4 illuminates
  4. mPiFaceDigital2.setOutputPin(4, true);
  5. mPiFaceDigital2.setLED(4, true);
  6. // The two Relays are connected in parallel to output pins 0 and 1 respectively.
  7. // When you set output pin 0 high, LED 0 illuminates and Relay 0 activates.
  8. mPiFaceDigital2.setOutputPin(0, true);
  9. mPiFaceDigital2.setLED(0, true);
  10. mPiFaceDigital2.setRelay(0, true);
  11. // Later on
  12. mPiFaceDigital2.close();

More info on the MCP23S17: http://ww1.microchip.com/downloads/en/DeviceDoc/20001952C.pdf