Montana Tech of The University of Montana
Computer Science & Software Engineering

CSCI 255
Introduction to Embedded Systems
Fall 2011


Lab #9 - Keypad Adder

DUE: Mon Nov 14th, 2PM
You will be creating a simple adding machine using a 4x4 keypad and a 7-segment display. You will learn how to decode 16 keys using only 8 input lines as well as how to handle switch bounce.

The sum starts at zero and is displayed on a 7-segment display. The 7-segment display should be able to display a single hex digit, 0-F. The 16 keys on the 4x4 keypad do the following: You should handle switch bounce, only detecting a single event for one button push. You should wait for the button to be released before performing the add. If the sum exceeds 15, you should blank the 7-segment display. The user the has to press * to reset the sum to 0.

As a starting point, you can use adder.c. This file contains stubs for the functions described in the prelab. The file also contains the power savings idle sleep function based on timer0 that was shown in lecture. Here is the 7-segment display datasheet.

The keypad should be connected to P3 with keypad pin 1 connected to P3.0, keypad pin 2 connected to P3.1, and so on. The 7-segment display should be connected to P2 with P2.0 connected to segment A, P2.1 connected to segment B, and so on. The 7-segment display should be powered via a 330+ Ohm resistor.

The keypad needs to be decoded by scanning the four rows (or equivalently each of the four columns) looking for a button that is pressed (low signal). Your program only needs to behave properly when a single button is pushed. For details of keypad decoding, see the pre-lab slides.
Submission. Submit your program to the Lab #9 dropbox on Moodle. Be sure your submitted source file has the required header with your name, username, and a description of the program. Your program will be graded on functionality, readability and elegance.

Page last updated: August 16, 2012.  Copyright © 2011 by Keith Vertanen.