I2C....because PBP has built in I2C handling capabilities (sure, it's got serial and SPI also, but I find I2C a bit 'cleaner' if that makes any sense).
On the '154...
The '154 has 4 inputs to control the 16 outputs, it's also got an enable line which turns the chip on or off.
You take a 5th bit from the PIC and drive that enable line with it. If you're driving 2 '154's, you have to invert that 5th bit going to one of the '154's, that way when one is on, the other is off.
If you want to drive a whole load of '154's, you can take 17 '154's, connect 16 of them in parallel (with say D0-D3) except for the enable line, take the 17th '154, connect it to another 4 bits from the PIC (say D4-D7), and use each of the 17th '154's outputs to drive the other 16 '154's enable line. And you'll end up with 256 individually controllable outputs. (or you could do the same thing with a '138, but with 8 '154's instead of 16 of them, or just not use all of the outputs of that extra '154 connected to D4-D7).
Another thing, with the '154, all you'll get is ON and OFF, nothing in between. You mentioned that you want to vary the strength over time. The '154 won't do it because you can't run multiple channel pulse-width modulation through it. You could easily set up an 8 channel software driven pulse-width modulation program and drive a bank of MOSFETs with the PIC and control the magnets that way. I've done exactly this with an 18F8722 and bank of 22 RGB LEDs (66 individual LEDs total). Replace those LEDs with n-channel MOSFETs or a bunch of ULN2803A's and you've got instant magnet control (well, as long as your power supply can handle it and doesn't cause the PIC to reset!).
Let us know if I dumbed this down too far for you, or maybe not enough, or whatever. We'll get you straightened out...![]()





Bookmarks