This example project will show the character of key pressed and the number of times that key is pressed on the LCD screen. If a logic 0 is found the function returns a value according to the key pressed. This process is repeated for each row until a pressed key is found. As told before one of the pins of the row is kept at a logic 0 and the columns are checked for a logic 0. If no key is being pressed it returns zero. If any key is pressed it waits until the key is released and returns the corresponding character. The Delay() is used to make delay in the program execution. #Buzzer interfacing with 8051 with c codeThe code consists of two user defined functions. Keil C Code #include //including sfr registers for ports of the controller P0.0 and P0.1 pins are pulled up externally using 10KΩ resistors since Port P0 has no internal pull up. Keypad is connected to the Port P1 and column inputs pins are pulled up internally. We can choose the required frequency by changing the crystal and clock frequency in the project settings of Keil C. 12MHz crystal is used to provide required clock for the microcontroller and 22pF capacitors will stabilize the oscillations of the crystal. Interfacing with 8051 Microcontroller Circuit diagram Interfacing Keypad with 8051 Microcontroller using Keil Cġ0KΩ resistor and 10μF will provide the required Power On Reset (POR) signal to the 8051 microcontroller. If you need to save more pins of your microcontroller then you can interface keypad using the ADC module of your microcontroller. If any switch belongs to 1 st row is pressed corresponding column will pulled down (logic LOW) and we can detect the pressed key. A logic LOW is given to Row1 and others (Row2 – Row-4) HIGH.Now we can read the status of each switch through scanning. In the normal case all the column pins are pulled up (HIGH state) by internal or external pull up resistors. For the sake of explanation lets assume that all the column pins (Col1 – Col4) are connected to the inputs pins and all the row pins are connected to the output pins of the microcontroller. The status of each keys can be determined by a process called Scanning. But by connecting switches in the following way we can read the status of each switch using 8 pins of the microcontroller. In the straight forward way to connect a 4×4 keypad (16 switches) to a microcontroller we need 16 inputs pins. We know that matrix keypad is made by arranging push button switches in row and columns. Matrix Keypads are commonly used in calculators, telephones etc where a number of input switches are required. 2 Interfacing with 8051 Microcontroller.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |