Sure we could use the PICAXE-18
or PICAXE-28
when we need more inputs and outputs (both of
which
have significantly more i/o pins) but that would defeat the purpose of using a
small, low-cost chip.
Fortunately there is a simple solution. By using 74xx165 and
the 74xx595 shift registers, we can expand the number of input and output ports
in multiples of eight.
Fig.1 shows how. In Fig.1a a 74xx165 is being used to expand
the number of inputs to eight. This requires three of the PICAXE ports; one for
serial data, one for clocking the shift register, and one for latching the data
into the shift register.
The 74xx165 also has a serial output port making it possible to
daisy chain multiple 165's to achieve even more inputs.
To read 8 input lines from a single 74xx165 the PICAXE-08 code
is: -