Microcontrollers Lab LAB #4: LCD + Keypad <Student 1 Name> <Student 1 ID> <Student 2 Name> <Student 2 ID> Start Date: September 10, 2013 Due date: September 17, 2013 (R): Section to be submitted in report (P): Section to be showed in LAB I. Pre-LAB. 1. (R) Given the following programs, compile them in your favorite C IDE like Dev-C (http://www.bloodshed.net/download.html.) Add a screenshot of the console output. Explain the reason of that result. Code LAB #4 – LCD + Keypad Output Explanation 1/6 Microcontrollers Lab LAB #4 – LCD + Keypad 2/6 Microcontrollers Lab 2. (R) Explain the behavior of the circuit shown in Figure 1. Figure 1. Keypad Circuit A: 3. (R) Regular keypad scanning algorithms set all MCU pins connected to columns as outputs simultaneously. There is a high risk of a short circuit if two keys are pressed at the same time. Explain why this is possible. A: 4. (R) The keypad scanning algorithm presented in the project avoids this problem. How? A: 5. (R) Explain the function get4NumericKeys() found in the keypad.c file. What is the role of the variable ptr? A: LAB #4 – LCD + Keypad 3/6 Microcontrollers Lab II. In-LAB 1. (P) Wire the circuit in figure 2. Note: the keypad pins are numbered assuming a bottom view, and counting them from right to left. Figure 2a. LAB4 Circuit LAB #4 – LCD + Keypad 4/6 Microcontrollers Lab Figure 2b. LAB4 Hardware Connections (photo) 2. (P) Implement a security box based on the state-machine in figure 3 using the following specifications: Two combinations for opening the box: o Manager key (secret: 9876) o User key (seed: 1111) When in open state: o Write “State: Open” in the LCD. o If a new combination is entered, then the new combination becomes the user key. o If the door is closed (emulated by pressing the user button) then new state = closed state. When in closed state o Write “State: Closed” in the LCD. o If a combination is introduced, it is compared with the user combination. If the combination introduced is equal to the user combination, then the door is open and new state = open state. Use a switch-case control structure for the implementation. Figure 3. State-machine for security box 3. (R) Incorporate here the c file that solves this exercise. Your code must be fully commented. 4. (P) Extension o When in open state and a new combination is entered, ask for confirmation (the new confirmation is entered twice). If both are equal, then the new combination is accepted. o When state = closed, if three times a wrong user combination is introduced, then the system gets blocked and only the manager combination will be accepted (unknown by the user). o (R) Incorporate here the c file that solves this exercise. Your code must be fully commented. LAB #4 – LCD + Keypad 5/6 Microcontrollers Lab II. Post-LAB. 1. Please, answer the following questions (this section is not optional). a) Explain why state machines are useful for modeling embedded systems. Document your answer. A: b) Present two possible applications for the knowledge you have acquired doing this lab. Elaborate your answer. A: LAB #4 – LCD + Keypad 6/6
© Copyright 2026 Paperzz