keybrd library is an open source library for creating custom-keyboard firmware.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

PCA9655E_2_scan.ino 1.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /* PCA9655E_2_scan.ino
  2. power IO0_2 and read IO1_1 (similar to strobe and read on key matrix)
  3. DESTINATION PIN PIN_NUMBER PIN DESTINATION
  4. x INT 1 24 VDD Teensy LC 3.3V
  5. SCL AD1 2 23 SDA Teensy LC 18
  6. GND AD2 3 22 SCL Teensy LC 19
  7. GND IO0_0 4 21 AD0 SCL
  8. GND IO0_1 5 20 IO1_6 x
  9. IO1_1 IO0_2 6 19 IO1_5 x
  10. GND IO0_3 7 18 IO1_4 x
  11. GND IO0_4 8 17 IO1_4 x
  12. GND IO0_5 9 16 IO1_3 x
  13. x IO0_6 10 15 IO1_2 x
  14. x IO0_7 11 14 IO1_1 IO0_2
  15. GND VSS 12 13 IO1_0 x
  16. */
  17. #include "Wire.h"
  18. const uint8_t ADDR = 0x18; //I2C address with AD2=GND AD1=SCL AD0=SCL
  19. void setup()
  20. {
  21. delay(1000);
  22. Serial.print("PCA9655E_2_read.ino");
  23. Wire.begin();
  24. //Configure port 1 to output
  25. Wire.beginTransmission(ADDR);
  26. Wire.write(7); //command byte 7 = Configuration dir Port 1
  27. Wire.write(0); //0=output
  28. Wire.endTransmission();
  29. Wire.beginTransmission(ADDR);
  30. Wire.write(3); //command byte 3 = Output Port 1
  31. Wire.write( 1<<1 ); //1=high
  32. Wire.endTransmission();
  33. //Configure port 0 to input
  34. Wire.beginTransmission(ADDR);
  35. Wire.write(6); //command byte 6 = Configuration dir Port 0
  36. Wire.write(~0); //1=input
  37. Wire.endTransmission();
  38. Wire.beginTransmission(ADDR);
  39. Wire.write(0); //command byte 0 = Input Port 0
  40. Wire.endTransmission(false); //PCA9655E needs false to send a restart
  41. Wire.requestFrom(ADDR, 1u); //request one byte from input port
  42. Serial.print(" port0_val= ");
  43. uint8_t port0_val = Wire.read();
  44. Serial.print(port0_val, BIN); //expect xx000100
  45. }
  46. void loop() { }