On the right you can see the code which I wrote to read numbers and digits. Note how the code is split into two functions, one to read the digit and another to create the finished value. This has been done so that I can replace the keypad with another and just change the keypad reading software.

The function get_value returns with an integer which is the one which has just been entered. It also displays the number as it is entered (which is probably not a good idea in a high security installation)

If you run Exercise 7.3 you will be able to enter digits using LB0 to LB7 and see a four digit number appear on the 7 segment LED display.