Tag Archives: keyboard

PS2 Keyboard Interface with AVR MCU

A PC keyboard is an old and trusted human machine interface. Most peoples are familiar with it. When a text entry is required it is the best method. If we can interface the PC keyboard with an AVR MCU we can create a whole lot of interesting applications! This tutorial will focus on our easy to use PS2 keyboard library for AVR MCU. Fig. 1 – A PC Keyboard(PS2 Type).   The PS2 Keyboard Library for AVR The PS2 Keyboard library for AVR has only two functions one for initializing the library and one for reading a ASCII character from the queue. The keyboard library automatically translates the scan codes to ASCII characters and buffers them in a FIFO queue. That means even if the CPU is busy doing something else and a character arrives from the keyboard, it will be automatically buffered in a queue. After that the CPU can read the characters anytime when it is free. void InitPS2() Function to initialize the PS2 keyboard library. Internally it initialize the ps2 system and sets up the INT0 isr for handling PS data traffic. Arguments: NONE Return Value: NONE   char ReadFromKbdQ(uint8_t wait) Function to read a character from the keyboard buffer. The wait parameter can be 0 or non zero. When wait is non zero the the function […]

4×3 Matrix Keypad Interface – AVR Tutorial

Many application requires large number of keys connected to a computing system. Example includes a PC keyboard, Cell Phone keypad and Calculators. If we connect a single key to MCU, we just connect it directly to i/o line. But we cannot connect, say 10 or 100 keys directly MCUs i/o. Because :- It will eat up precious i/o line. MCU to Keypad interface will contain lots of wires. Buy Matrix Keypad We want to avoid all these troubles so we use some clever technique. The technique is called multiplexed matrix keypad. In this technique keys are connected in a matrix (row/column) style as shown below. Matrix Keypad Basic Connection The rows R0 to R3 are connected to Input lines of Microcontroller. The i/o pins where they are connected are made Input. This is done by setting the proper DDR Register in AVR and TRIS Register in PIC. The column C0 to C3 are also connected to MCUs i/o line. These are kept at High Impedance State (AKA input), in high z state (z= impedance) state these pins are neither HIGH or LOW they are in TRISTATE. And in their PORT value we set them all as low, so as soon as we change their DDR bit to 1 they become output with value LOW. One by One we make each […]