My brain’s been churning on this one. I want to drive the MT8816, which requires 8 different bits plus a strobe and reset, I need discrete inputs and outputs, I want buttons, I want a display… too many things, not enough pins. Yes, I can switch to a Mega, but I don’t need all the extra memory and cost, and it still leaves me short of what I need to do all that. .
Then I find solutions.
I’ve already discussed the use of the Serial to Parallel chip. This cut my 8 bits into a single serial data line, plus a strobe and reset.
I stumbled on a great solution for the display – they’ve come up with I2C drivers for the standard 16×2 display modules… this makes life REALLY easy! Two pins for the display, plus 5V and ground, and it works like a champ. Best part? FOUR displays with I2C adaptors (some assembly required) for 12 bucks on amazon. As long as they work (and mine did), it’s a great deal.
As soon as I got the display connected and a “Hello World” program running, I started tinkering with the sketch I had working. Previously, I had gotten a 3-button setup to allow me to cycle through Y outputs (push a button, deactivate the output, activate the next one, all on X0). Now, I set Button 2 to scroll through Y values (display “OUTPUT”), and show the value on the screen. Similarly, Button 1 scrolls through X values and the display shows “INPUT”. Out of boredom, I played with the text.
Obviously, I don’t have BUTTONS, so I’m just grounding the corresponding wires to simulate button pushes. They’re debounced in code.
Next, I want to try an I2C connected GPIO expander, like the Microchip MCP23017. This would allow me to tie on to the I2C bus (already in use, so just addressing things correctly) and get 16 new IO pins. As an added bonus, it provides interrupts, which can be used to drive the Arduino. The upshot is that with 2 additional Arduino pins (the interrupt and reset), I can now have 8 inputs and 8 outputs to work with for radio interfaces (COS, PTT). Since these are bussed and addressable, I COULD even use a second one to handle things like the control buttons… but that’s a bit more than I want to tackle now.
Just counting… right now my Arduino GPIO pins are allotted as follows (or will be when I get the 23017):
Pin | Connected To | Function |
---|---|---|
0 | Spare | UART / GPIO |
1 | Spare | UART / GPIO |
2 | 23017, Provisioned | Interrupt Input |
3 | Spare | GPIO |
4 | Spare | GPIO |
5 | SN7LV8153 | DATA (Serial) |
6 | 23017, Provisioned | Reset |
7 | SNLV8153 | Reset, Active LOW |
8 | MT8816 | Reset, Active HIGH |
9 | MT8816 | Strobe, Active HIGH |
10 | Button 1 | Active LOW |
11 | Button 2 | Active LOW |
12 | Button 3 | Active LOW |
13 | (LED) | N/A |
14 | I2C Bus | SDA |
15 | I2C Bus | SCL |
So Pins 3 and 4 are unused at this point, and can be used for future interrupts for IO expanders or other purposes. Pins 0 and 1 are the on-board UART pins, and are also unused, but I could use them for either serial (unlikely) or additional GPIO, if I needed them.
If I need more SN74LV8153 functionality, I can drive multiple chips from the same data line – they just need to be addressed. The same is true of the I2C bus, which will now allow a display AND 16 additional IO lines, as I described before.