I would like to use the Jeelabs Output Plug for 4 bits OUT and 4 bits IN.
When I run the program below, I get no change when jumping a resistor across 3v or Gnd to P0-7, using the 12 pin pad on the outside of the darlington 2803 chip.
The 12pin access plug is on the other side of the 2803 Darlington chip, can this chip be read from as well as write to?, I have had no success.
I have cut a track between then I2C-p7 and the 2803, and put an input wire to the P0-7 pins of the I2C chip, but had to increase voltage to 5V for a TTL -CMOS to change state. I have tried this and it produces some results but very difficult to solder, and seems to cause problems. Is there a better way to do this?, thanks.
#include
int sWas =0; PortI2C myport (1 /, PortI2C::KHZ400 /); DeviceI2C expander (myport, 0x26); // also works with output plug if 0x26/0x27 enum { MCPIODIR, MCPIPOL, MCPGPINTEN, MCPDEFVAL, MCPINTCON, MCPIOCON, MCPGPPU, MCPINTF, MCPINTCAP, MCPGPIO, MCPOLAT };
void setup() {
}
void loop() {
expsetup();
Serial.begin(9600);
Serial.print("\nREARGUARD-MAIN;
Serial.println("LRBT\tLIGHTS");
} checkSwitches();
void checkSwitches() { // when reading remember resets output port afterwards ? byte outputPort=expread(); // if (outputPort == 0) return; if (sWas !=outputPort){ Serial.println(outputPort,BIN); sWas = outputPort; delay(500); } }
static void expsetup () {
} expander.send();
expander.write(MCPIODIR);
expander.write(0);// to 4 bit out-bottom 4 in was =0
expander.stop();
static void expwrite (byte value) {
} expander.send();
expander.write(MCPGPIO);
expander.write(value & 15); // top 4 bits for out
expander.stop();
static byte expread () {
}
expander.send();
expander.write(MCPGPIO);
expander.receive();
byte result = expander.read(1);//x & 240;// bottom 4 bits for in was 1
expander.stop();
return result;
