Am I correct in thinking that the 16 Push buttons are connected to the first 2 boards P0 ... P7 and LED outputs are connected to the second 2 boards P0 ...P7 so 4 boards in all as per your Void Setup()
Serial.println(F("Multi IoExpander - pins 0..99 reserved for Arduino, 100..115 for buttons, 116..135 for LEDs"));
Serial.println(F("setting up 4x PCF8574 at I2C addresses 0x20 to 0x23"));
// we add a 8574 (EXPANDER A with I2C address 0x20) that allocates 8 more pins, therefore it goes from 100 to 107
multiIoAddExpander(multiIo, ioFrom8574(0x20), NB_PINS_PER_PCF8574);
// we add a 8574 (EXPANDER B with I2C address 0x21) that allocates 8 more pins, therefore it goes from 108 to 115
multiIoAddExpander(multiIo, ioFrom8574(0x21), NB_PINS_PER_PCF8574);
// we add a 8574 (EXPANDER C with I2C address 0x22) that allocates 8 more pins, therefore it goes from 116 to 123
multiIoAddExpander(multiIo, ioFrom8574(0x22), NB_PINS_PER_PCF8574);
// we add a 8574 (EXPANDER D with I2C address 0x23) that allocates 8 more pins, therefore it goes from 124 to 131
multiIoAddExpander(multiIo, ioFrom8574(0x23), NB_PINS_PER_PCF8574);
Am I correct in thinking that the 16 Push buttons are connected to the first 2 boards P0 ... P7 and LED outputs are connected to the second 2 boards P0 ...P7 so 4 boards in all as per your Void Setup()
Yes John, that's the way i wrote the sketch, with all pins for buttons on the first 2 expanders, and the LEDs on the remaining 2 expanders
Eric
Great I have only 2 boards at the moment so have just ordered 4 more from China so may take a while before can try...
John
Ok John, then you may want to try this stripped-down version for 1x PCF8574 with buttons + 1x PCF8574 with LEDs
I think you'll have to reverse the way the LED ports get a HIGH or LOW, because the PCF8574 sinks current, so the LEDs should be wired between the PCF port and VCC, rather than GND.
Eric
Thanks for that I will have a play over weekend, I want to get more done on layout but I have in Garage know and the weather turn a lot cooler so probably not get much done on that, the video I watched was very good and a basic help...
John
Hi Eric you didnt modify this line so did you make 100 to 107 buttons and 108 to 115 are LED's...
Serial.println(F("Multi IoExpander - pins 0..99 reserved for Arduino, 100..115 for buttons, 116..135 for LEDs"));
John
Yes John, sorry I didn't update all comments consistently.
Basically from the full-blown version, we only keep Expanders A and C, A being for buttons and C for LEDs, so buttons = 100..107 and LEDs = 108..115
Expander C is now right after A and you can choose any I2C address for both as long as they are not equal and you update the sketch accordingly on the 2 lines with code like :
multiIoAddExpander(multiIo, ioFrom8574(0x20), NB_PINS_PER_PCF8574);
multiIoAddExpander(multiIo, ioFrom8574(0x21), NB_PINS_PER_PCF8574);
So you can use 0x20 and 0x21 for example, or 0x20 and 0x22 to stay in line with the original sketch. The important point is that C immediately follows A, and i kept the code refering to EXPANDER_A and EXPANDER_C so this line was updated :
#define EXPANDER_C (EXPANDER_A + NB_PINS_PER_PCF8574) //2nd PCF8574 will have "abstract pins" 108-115
Eric
Hi Eric, just a minor problem error as dont have this library "IoAbstractionWire.h" and did a search on name but nothing came up ...
Got the first one Okay
#include <IoAbstraction.h>
#include <IoAbstractionWire.h> //this one does also : #include <Wire.h>
John
Its okay the first one must have had the library for Wire and complied okay
Well it does work but in a strange sort of way hope this video will send..
No it wont its 187mb long if you let me have your email I will send via Wetransfer..
So list of what is happening ...
Press 8 and 1 together , then press 1, 8 goes out
Press 7 and 1 together , then press 1, 7 goes out
Press 6 and 1 together , then press 1, 6 goes out
all the same down to 2
Press 1 and 2 together, then press 1, 2 goes out
to get 1 to come on or go off you have to press 1 first then 2
all these operations are same for switvch on..
You have to Press the LED button 2 to 8 and button 1 together
I have all wired correctly P0 .... P7 Button 1 to 8 address 0x20 jumpers on board all low
LED's on second board P0 ..... P7. LED's. 1 to 8 address 0x21 Jumper A0 high A1 , A2 Low
Also LED 1 seems to respond when sometimes buttons 1 through 5 are pressed but not 6,7or 8
John
Re-reading the sketch, I think you'll have to reverse all the conditions, and initializations, because your original sketch was based on the buttons going HIGH when pressed, and the LEDs lighting when you set their pins to HIGH, but we are now on a global "active LOW" setup.
It may be easier - and cleaner, for conversion between "active-LOW" and "active-HIGH" setups, to use some defines along these lines (that is, if I understood your original code correctly...) :
Eric
Also John try to make some basic tests to validate we have all HIGH/LOW right :
- does everything look ok (all LEDs off, nothing coming on the serial monitor) before you press any button
- do the single button press give the proper output in the monitor
- do the LEDs light on/off according to the serial output
Then when all the basics are ok we can analyze what happens with multi-button press
Eric
Hi Eric ... I will check that out tomorrow, the push buttons go low to activate and the LED's are also Low to activate...
Will aso use the sketch you added...
Regards John
Hi Eric,
This latest sketch is nearly there, but you have to press another button before one thats lit will go out i.e
If you press 1 LED comes on Press 1 LED stays on, Press 2 LED comes on Press 1 LED1 goes out, 678 dont work at all... a couple of serial monitor screen shots,,, always forget for debugging..