## Pin I/O

Our last test program just rebooted to ISP immediately on startup. Next
thing we want to test some pin input/output.

Let’s recall the pin assignments from disassembling the stock firmware.

* P3.1 [in] DIP switch 4
* P3.2 [in] DIP switch 3
* P3.5 [out] LED 3 (Num Lock by default)
* P3.6 [out] LED 1 (Caps Lock)
* P3.7 [out] LED 2 (Scroll Lock)
* P4.1 [in] DIP switch 2
* P4.2 [in] DIP switch 1
* P4.3 [in] DIP switch 5

Also, we have a bunch of pins connected to the key matrix (P1.0÷7,
P2.0÷7, P3.3, P3.4 select a column, then P0.0÷7 give states of the keys
in that column). But that’s for later.

All these I/O pins are negated: a 0 value indicates a LED, a DIP switch
or a matrix line is active.

This time we will first query the DIP switch 4. If it is in the ON
position (0), we proceed to the main program. If OFF, we reboot to the
ISP mode.

The main program will turn on the middle LED and then just do nothing.