Sunteți pe pagina 1din 26

Light-emitting diode (LED)

Light-emitting diodes are elements for light signalization in electronics. They are manufactured in different shapes, colors and sizes. For their low price, low power consumption and simple use, they have almost completely pushed aside other light sources, bulbs at first place. They perform similar to common diodes with the difference that they emit light when current flows through them.

It is important to limit their current, otherwise they will be permanently destroyed. For this reason, a conductor must be connected in parallel to an LED. In order to determine value of this conductor, it is necessary to know diodes voltage drop in forward direction, which depends on what material a diode is made from and what colour it is. Typical values of the most frequently used diodes are shown in table below. As seen, there are three main types of LEDs.Standard ones get ful brightness at current of 20mA. Low Current diodes get ful brightness at ten times lower current while Super Bright diodes produce more intensive light than Standard ones.

Figure 1 shows how to interface the LED to microcontroller. As you can see the Anode is connected through a resistor to Vcc & the Cathode is connected to the Microcontroller pin. So when the Port Pin is HIGH the LED is OFF& when the Port Pin is LOW the LED is turned ON.

Flashing LED ALGORITHM


1. 2. 3. 4. Start. Turn ON LED. Turn OFF LED. GO TO 2.

We now want to flash a LED. It works by turning ON a LED & then turning it OFF & then looping back to START. However the operating speed of microcontroller is very high so the flashing frequency will also be very fast to be detected by human eye.

Modified Flashing LED ALGORITHM


1. 2. 3. 4. 5. 6. Start. Turn ON LED. Wait for some time (delay). Turn OFF LED. Wait for some time (delay). Go To 2.

You can see in the modified algorithm that after turning ON the LED the controller waits for the delay period & then turns OFF the led & again waits for the delay period & then goes back to the start. 1. ORG 0000h.

2. 3. 4. 5. 6. 7.

loop: CLR P2.0 CALL DELAY SETB P2.0 CALL DELAY JMP loop

In the above program LED is connected to P2.0. Seg displays are are basically 7 LED's. It will be much easier to understand if you first read Interfacing LED's to Microcontroller.

Basically there are two types of 7-Seg display's: Common Cathode where all the segments share the same Cathode. Common Anode where all Segments share the same Anode.

Here we will be only discussing the Common Anode type.In common Anode in order to turn ON a segment the corresponding pin must be set to 0. And to turn it OFF it is set to 1.

Controller P2.0 P2.1 P2.2 P2.3 P2.4 P2.5 P2.6

Figure 2 7-seg display A B C D E F G

Figure 1 shows how to interface 7-seg display to a microcontroller. Now we create a lookup table containing the seven segment pattern to display the corresponding hex digits. e.g. consider we have to display '1' from the above figure we come to know that turning ON segment B & C will show '1' on the 7-seg display so P2.1 & P2.2 should be LOGIC 0 whereas rest of the pins should be LOGIC 1. FIGURE 2 shows the lookup table for CA display.

Figure 3

We can now interface a single 7-Seg to the microcontroller but for interfacing multiple 7-seg's we use Scanning Principle where One 7-seg is displayed after another but this process is very fast hence the flickering cannot be seen by human eye. Figure 3 shows the circuit for interfacing two 7 seg displays.

When interfacing more than one 7-seg display the segment's (A-G) of all displays are connected together whereas their ANODE (Cathode in case of CC displays) are switched ON one after another. Consider we have to display '31' on the above 7-seg display so we TURN ON the first transistor by setting its corresponding pin to 1 & then give the 7seg equivalent code for '3' which is 4fh. Then we TURN OFF the first transistor & TURN ON the second & output its corresponding 7-seg equivalent code of '1' i.e. 06h.Then we again go back to display '3' this is a never ending loop. ORG 0000h CLR P3.0

CLR P3.1 MOV P2,#0ffh loop: CLR P3.0 SETB P3.1 MOV P2,#4fh CALL delay CLR P3.1 SETB P3.0 mov P2,#06h CALL delay AJMP loop

Relays are devices which allow low power circuits to switch a relatively high Current/Voltage ON/OFF. For a relay to operate a suitable pull-in & holding current should be passed through its coil. Generally relay coils are designed to operate from a particular voltage often its 5V or 12V. The function of relay driver circuit is to provide the necessary current (typically 25 to 70ma) to energize the relay coil.

Figure 1

Figure 1 shows the basic relay driver circuit. As you can see an NPN transistor BC547 is being used to control the relay. The transistor is driven into saturation (turned ON) when a LOGIC 1 is written on the PORT PIN thus turning ON the relay. The relay is turned OFF by writing LOGIC 0 on the port pin. A diode (1N4007/1N4148) is connected across the relay coil, this is done so as to protect the transistor from damage due to the BACK EMF generated in the relay's inductive coil when the transistor is turned OFF.When the transistor is switched OFF the energy stored in the inductor is dissipated through the diode & the internal resistance of the relay coil. As you can see we have used a pull up resistor at the base of the transistor. AT8951/52/55 has an internal pull up resistor of 10k so when the pin is pulled high the current flows through this resistor so the maximum output current is 5v/10K = 0.5ma, the DC current gain of BC547 is 100 so the maximum collector current we can get is 0.5ma x 100 = 50ma, but most of the relays require more than 70ma-130ma current depending on the relay that we have used, 0.5ma of base current is not suitable enough for turning ON the relay, so we have used an external pull up resistor. When the controller pin is high current flows through the controller pin i.e. 5v/10k=0.5ma as well as through the pull up resistor. We have used 4.7k pull up resistor so 5v/4.7k=1.1ma so maximum base current can be 0.5ma + 1.1ma=1.6ma i.e. collector current =1.6ma x 100 = 160ma which is enough to turn ON most of the relays.

LED displays
Basically, an LED display is nothing more than several LEDs moulded in the same plastic case. There are many types of displays composed of several dozens of built in diodes which can display different symbols.

Most commonly used is a so called 7-segment display. It is composed of 8 LEDs, 7 segments are arranged as a rectangle for symbol displaying and there is an additional segment for decimal point displaying. In order to simplify connecting, anodes and catodes of all diodes are connected to the common pin so that there are common anode displays and common catode displays, respectively. Segments are marked with the latters from A to G, plus dp, as shown in the figure on the left. On connecting, each diode is treated separtely, which means that each must have its own current limiting resistor. Displays connected to the microcontroller usually occupy a large number of valuable I/O pins, which can be a big problem especially if it is needed to display multy digit numbers. The problem is more than obvious if, for example, it is needed to display two 6-digit numbers (a simple calculation shows that 96 output pins are needed in this case). The solution to this problem is called MULTIPLEXING. This is how an optical illusion based on the same operating principle as a film camera is made. Only one digit is active at a time, but they change their state so quickly making impression that all digits of a number are simultaneously active.

Here is an explanation on the figure above. First a byte representing units is applied on a microcontroller port and a transistor T1 is activated at the same time. After a while, the transistor T1 is turned off, a byte representing tens is applied on a port and a transistor T2 is activated. This process is being cyclically repeated at high speed for all digits and corresponding transistors. The fact that the microcontroller is just a kind of miniature computer designed to understand only the language of zeros and ones is fully expressed when displaying any digit. Namely, the microcontroller doesn't know what units, tens or hundreds are, nor what ten digits we are used to look like. Therefore, each number to be displayed must be prepared in the following way: First of all, a multy digit number must be split into units, tens etc. in a particular subroutine. Then each of these digits must be stored in special bytes. Digits get familiar format by performing masking. In other words, a

binary format of each digit is replaced by a different combination of bits in a simple subroutine. For example, the digit 8 (0000 1000) is replaced by the binary number 0111 111 in order to activate all LEDs displaying digit 8. The only diode remaining inactive in this case is reserved for the decimal point. If a microcontroller port is connected to the display in such a way that bit 0 activates segment a, bit 1 activates segment b, bit 2 segment c etc., then the table below shows the mask for each digit.

Digits to display dp 0 1 a 0 b 0

Display Segments c 0 d 0 e 0 f 0 g 1

1 2 3 4 5 6 7 8 9

1 1 1 1 1 1 1 1 1

0 0 0 1 0 0 0 0 0

0 0 0 0 1 1 0 0 0

1 1 0 0 0 0 0 0 0

1 0 0 1 0 0 1 0 0

1 0 1 1 1 0 1 0 1

1 1 1 0 0 0 1 0 0

1 0 0 0 0 0 1 0 0

In addition to digits from 0 to 9, some letters of alphabet - A, C, E, J, F, U, H, L, b, c, d, o, r, t - can also be displayed by performing appropriate masking. If the event that common chatode displays are used all units in the table should be replaced by zeros and vice versa. Additionally, NPN transistors should be used as drivers as well.

This 8051 asm source code can be simulated using simulator Edsim51 ; This program multiplexes the number 1234 ; on the four 7-segment displays. ; Note: a logic 0 lights a display segment. start: SETB P3.3 ; | SETB P3.4 ; | enable display 3 MOV P1, #11111001B ; put pattern for 1 on display MOV P1, #0FFH ; clear the display CLR P3.3 ; enable display 2 MOV P1, #10100100B ; put pattern for 2 on display MOV P1, #0FFH ; clear the display CLR P3.4 ; | SETB P3.3 ; | enable display 1 MOV P1, #10110000B ; put pattern for 3 on display MOV P1, #0FFh ; clear the display

CLR P3.3 ; enable display 0 MOV P1, #10011001B ; put pattern for 4 on display MOV P1, #0FFH ; clear display JMP start ; jump back to start

Decimal Counter Using Two 7-segment displays and an 8051.


Introduction
The purpose of this lab is to implement a decimal counter which counts from 0 to 99. You will have to write a C program for the 80X51 micro-controller. You will then compile your C program using C51 compiler and burn it unto an 8051 stand alone chip. You will also have to do some wiring in this lab. The 8051 chip requires some connections to function properly, and the 7-segment displays need to be wired to the 8051. Schematics are provided below. Before you can write your C program, you have to understand how the 7-segment displays work. The 7-segment displays used in the lab are the LSD5061-11 display. Each of the segment corresponds to a pin (see below for the pinout). In order to light up a particular segment, it's pin must be set to 0V. Since these pins are connected to the 8051, we simply set the corresponding pin on the 8051 to '0'. To turn a segment off, the pin must be set to 5V. This is done by setting the corresponding pin on the 8051 to "1". Instead of going through each of the seven pins and setting them to '1' or '0' each time we want to display a number, we will use a lookup table unsigned char LookupTable[11] = { }. The location of the entry in the table corresponds to the correct pin settings to display that number. Simply, LookupTable[0] returns the correct pin settings to display a "0" on the 7-segment display. Now we have to figure out the correct entries into the table. We know that in order to display a "0" on the 7-segment display we need to turn on segments s1, s2, s3, s4, s5, and s6. To turn a segment on, we set the corresponding pin to "0". Segment s7 will need to be turned off. To turn off this segment we set the corresponding pin to "1". Therefore, the pins will need to be assigned the following values: P2^0 = 0; P2^1 = 0; P2^2 = 0; P2^3 = 0; P2^4 = 0; P2^5 = 0;

P2^6 = 0; P2^7 = 1; P2^8 = 1; //don't care what this value is since it is not used We set it to 1 because the 8051 pins are by default 1 The bit pattern desired is 1100 0000 (remeber that pin 8 is the highest bit). We then convert the values into hexadecimal 1100 -> C and 0000 -> 0. We fill in the table with this value 0xC0. The "0x" is needed before the actual value to indicate to the compiler that it is a hexadecimal value. Now when we call LookupTable[0] it will return the proper configuration to display a "0" on the 7-segment display. You will need to fill in the rest of the values (1-9). LookupTable[10] will indicate an error has occured, at this location segment s7 will be on, the remaining segments will be off. (If you want, you can also look at the 7-segment display datasheet.) LSD5061-11 Pin number pin 1 pin 2 pin 4 pin 6 pin 7 pin 9 pin 10 8051 pin number 8051 pin number (One's place display) (Ten's place display) P2.0 P3.0 P2.1 P3.1 P2.2 P3.2 P2.3 P3.3 P3.4 P2.4 P2.5 P3.5 P2.6 P3.6

Segment number s1 s2 s3 s4 s5 s6 s7

Assignment
In this lab :

You will implement a decimal counter using the C programming language for the 8051 micro-controller and display the count (0 to 99) on two 7-segment displays. You will then burn your program on the 8051.

Make necessary connections the 8051 chip and the two 7-segment displays. Verify the correctness of your circuit.

Apparatus Required
1. 2. 3. 4. 5. 330 resistors (4) 7-segment display (2) 5V power supply 8051 chip 12MHz crystal (clock)

Schematic

Program
#pragma SMALL DB #include /* P0, P1, P2 and P3 are predefined port names and are bit addressable */ unsigned char SetDisplay(unsigned char value){ unsigned char LookupTable[11] = { 0xC0, ... };

/* check to see if "value" is in bounds, if not return an error */ if( ) { /* return appropriate value */; } else { /* return error value */; }

/* Delay function */ void delay() { int i, j; for(i=0; i<1000; i++) for(j=0; j<100; j++) i = i + 0; } void main(void){ unsigned char count = 0;

/* value held in one's place */

while(1) { /* determine and display the one's place */ /* determine and dipslay the ten's place */ /* update the counter (remember to keep it within bounds)*/ } } delay();

even Segment Display Interfacing


The 7 segment display is found in many displays such as microwaves or fancy toaster ovens and occasionally in non cooking devices. It is just 7 LEDs that have been combined into one case to make a convenient device for displaying numbers and some letters. The display is shown on the left. The pin out of the display is on the right.

This version is a common anode version. That means that the positive leg of each LED is connected to a common point which is pin 3 in this case. Each LED has a negative leg that is connected to one of the pins of the device. To make it work you need to connect pin 3 to 5 volts. Then to make each segment light up, connect the ground pin for that led to ground. A resistor is required to limit the current. Rather than using a resistor from each LED to ground, you can just use one resistor from Vcc to pin 3 to limit the current. The following table shows how to form the numbers 0 to 9 and the letters A, b, C, d, E, and F. '0' means that pin is connected to ground. '1' means that pin is connected to Vcc.

To Display 0 1 2 3 4 5 6 7 8 9 A b C d E

a (Pin 1) 0 1 0 0 1 0 0 0 0 0 0 1 0 1 0

b (Pin 10) 0 0 0 0 0 1 1 0 0 0 0 1 1 0 1

c (Pin 8) 0 0 1 0 0 0 0 0 0 0 0 0 1 0 1

d (Pin 6) 0 1 0 0 1 0 0 1 0 1 1 0 0 0 0

e (Pin 5) 0 1 0 1 1 1 0 1 0 1 0 0 0 0 0

f (Pin 2) 0 1 1 1 0 0 0 1 0 0 0 0 0 1 0

g (Pin 9) 1 1 0 0 0 0 0 1 0 0 0 0 1 0 0

Now, we want to run the display with the AT89C51 microcontroller. We will use Port 0 to run the display. Connect the AT89C51 to the 7 segment display as follows.

Program to display "0" on the seven segment display


; PROG2 - Second Program, Display 0 on seven segment display ; ORG 0000H ; Execution starts here SETB CLR CLR CLR CLR CLR CLR P0.3 P0.1 P0.0 P0.6 P0.5 P0.4 P0.2 ; Turn off the g segment ; Turn on the a segment ; Turn on the b segment ; Turn on the c segment ; Turn on the d segment ; Turn on the e segment ; Turn on the f segment ; Loop here forever

HERE: AJMP HERE END

Switches and Pushbuttons


There is nothing simpler than this! This is the simplest way of controlling appearance of some voltage on microcontrollers input pin. There is also no need for additional explanation of how these components operate.

Nevertheless, it is not so simple in practice... This is about something commonly unnoticeable when using these components in everyday life. It is about contact bounce- a common problem with m e c h a n i c a l switches. If contact switching does not happen so quickly, several consecutive bounces can be noticed prior to maintain stable state. The reasons for this are: vibrations, slight rough spots and dirt. Anyway, whole this process does not last long (a few micro- or miliseconds), but long enough to be registered by the microcontroller. Concerning pulse counter, error occurs in almost 100% of

cases!

The simplest solution is to connect simple RC circuit which will suppress each quick voltage change. Since the bouncing time is not defined, the values of elements are not strictly determined. In the most cases, the values shown on figure are sufficient. If complete safety is needed, radical measures should be taken! The circuit, shown on the figure (RS flip-flop), changes logic state on its output with the first pulse triggered by contact bounce. Even though this is more expensive solution (SPDT switch), the problem is definitely resolved! Besides, since the condensator is not used, very short pulses can be also registered in this way.

In addition to these hardware solutions, a simple software solution is commonly applied too: when a program tests the state of some input pin and finds changes, the check should be done one more time after certain time delay. If the change is confirmed it means that switch (or pushbutton) has changed its position. The advantages of such solution are obvious: it is free of charge, effects of disturbances are eliminated too and it can be adjusted to the worstquality contacts. Disadvantage is the same as in case of using RC filter-pulses shorter than program delay cannot be registered. In 8051 PORT 1, PORT 2 & PORT 3 have internal 10k Pull-up resistors whereas this Pull-up resistor is absent in PORT 0. Hence PORT 1, 2 & 3 can be directly used to interface a switch whereas we have to use an external 10k pull-up resistor for PORT 0 to be used for switch interfacing or for any other input. Figure 1 shows switch interfacing for PORT 1, 2 & 3. Figure 2 shows switch interfacing to PORT 0.

For any pin to be used as an INPUT PIN a HIGH (1) should be written to the pin if you dont do this the pin will always be read as LOW.In the above figure when the switch is not pressed the 10k resistor provides

the current needed for LOGIC 1 closure of switch provides LOGIC 0 to the controller PIN.Let's write a small program where whenever a switch is pressed a LED is turned ON. Consider that switch is connected to P2.0 & an LED connected to P2.1. PROGRAM 1 ORG 0000h SETB P2.0 SETB P2.1 loop1: JB P2.0,loop1 clr P2.1 loop2: JNB P2.0,loop2 SETB P2.1 AJMP loop1 First we initialize the Port Pins that we are using. Since we are using P2.0 as an Input Pin we write logic 1 to it (SETB P2.0). We are using PIN P2.1 for LED. Initially LED is turned OFF this is done by pulling the PIN HIGH (check LED interfacing Section). Now we check if the Switch is pressed or not. So we wait till switch is pressed (loop1: JB P2.0,loop1) as soon as switch is pressed the LED is TURNED ON ( CLR P2.1 ) . Then we wait till the switch to be released (loop2: JNB P2.0, loop2 ) & then we TURN OFF the LED (SETB P2.1). You must have noticed in the above program that the status of the input pin is same as that of Output Pin i.e. if the switch is not PRESSED (HIGH) the Output pin is also HIGH (LED OFF) & when the switch is PRESSED (LOW) the Output pin is also LOW (LED ON) using this logic we can write in another way. PROGRAM 2 ORG 0000h SETB P2.1 SETB P2.0 loop: MOV C,P2.0 MOV P2.1,C AJMP loop The Output of both the programs will be the same.Now you know the basic concept of switch interfacing. There is a problem in practically interfacing these switches to the controller. In the above case you have considered the switches to be an IDEAL SWITCH where when the

switch is pressed the controller directly gets LOGIC 0. But practically when a switch is closed the contacts open & close rapidly for about 30ms. This is called as SWITCH BOUNCING. Figure 3 shows its waveform.

Figure 3

As you can see the switch release is clean without any bouncing. When a switch is pressed the contacts open & close for about 20ms. In the above programs the LED will flicker initially when the switch is pressed because of the SWITCH BOUNCING but since the flickering will be very fast & will not be detected by human eye.Even though 20ms is very short time in human terms for a microcontroller it is a very long time. Without SWITCH DEBOUNCING the controller will think that the switch was pressed many times.Let us modify PROGRAM 1 & used SWITCH DEBOUNCING in it.

Switch Interfacing & Debouncing


Over here we consider ONE Switch & TWO LED connected to a microcontroller. Please check the SWITCH INTERFACING and the LED INTERFACINGarticle to see how to connect Switches & LEDs to a microcontroller. Here is a program that will TURN ON A LED1 if a switch is debounced properly & will TOGGLE LED2 if there is some error in switch debouncing. LED1 will be ON until the switch is pressed & will turn OFF as soon as its released. We have taken the debounce period as 20ms. So once a LOW signal has been received from the switch the controller will again check the switch status after 20ms & if at that time the switch is high LED2 will be toggled and if the switch is LOW LED1 will be turned ON.

led1

bit

P2.0

led2 switch1

bit bit

P2.1 P1.0

ORG 0000h setb switch1 setb led1 setb led2 wait: jb switch1,wait // Wait till switch1 has been pressed call debounce_delay jb switch1,c1_wait //switch low even after debouncing period //switch has been succesfully debounced clr led1 //Turn ON LED1 jnb switch1,$ //wait till switch has been released setb led1 //Turn OFF LED1 ajmp wait c1_wait: //Switch PIN high after debounce period so error in debouncing cpl led2 ajmp wait debounce_delay: //Subroutine for generating 20ms delay mov r7,#245 l1_debounce_delay: mov r6,#40 djnz r6,$ djnz r7,l1_debounce_delay ret END Keypad Interfacing...
...................................................................................................................................

//initialize switch 1 as input //Turn OFF LED1 //Turn OFF LED2

Keyboards and LCDs are the most widely used input/output devices of the 8051, and a basic understanding of them is essential. In this section, we first discuss keyboard fundamentals, along with key press and key detection mechanisms, Then we show how a keyboard is interfaced to an 8051. Interfacing the Keyboard to the 8051

At the lowest level, keyboards are organized in a matrix of rows and columns. The CPU accesses both rows and column through ports; therefore, with two 8-bit ports, an 8*8 matrix of keys can be connected to a microprocessor. When a key pressed, a row and column make a connect; otherwise, there is no connection between row and column. In IBM PC keyboards, a single microcontroller (consisting of microprocessor, RAM and EPROM, and several ports all on a single chip) takes care of software and hardware interfacing of keyboard. In such systems it is the function of programs stored in the EPROM of microcontroller to scan the keys continuously, identify which one has been activated, and present it to the motherboard. In this section we look at the mechanism by which the 8051 scans and identifies the key. Scanning and identifying the key Figure13.5 shows a 4*4 matrix connected to two ports. The rows are connected to an output port and the columns are connected to an input port. If no key has been pressed, reading the input port will yield 1s for all columns since they are all connected to high (Vcc) If all the rows are grounded and a key is pressed, one of the columns will have 0 since the key pressed provides the path to ground. It is the function of the microcontroller to scan the keyboard continuously to detect and identify the key pressed. How it is done is explained next.

Grounding rows and reading columns To detect a pressed key, the microcontroller grounds all rows by providing 0 to the output latch, and then it reads the columns. If the data read from the columns is D3D0=1111, no key has been pressed and the process continues until a key press is

detected. However, if one of the column bits has a zero, this means that a key press has occurred. For example, if D3-D0=1101, this means that a key in the D1 column has been pressed. After a key press is detected, the microcontroller will go through the process of identifying the key. Starting with the top row, the microcontroller grounds it by providing a low to row D0 only; then it reads the columns. If the data read is all1s, no key in that row is activated and the process is moved to the next row. It grounds the next row, reads the columns, and checks for any zero. This process continues until the row is identified. After identification of the row in which the key has been pressed, the next task is to find out which column the pressed key belongs to. This should be easy since the microcontroller knows at any time which row and column are being accessed. Assembly language program for detection and identification of key activation is given below. In this program, it is assumed that P1 and P2 are initialized as output and input, respectively. Program13.1 goes through the following four major stages: 1. To make sure that the preceding key has been released, 0s are output to all rows at once, and the columns are read and checked repeatedly until all the columns are high. When all columns are found to be high, the program waits for a short amount of time before it goes to the next stage of waiting for a key to be pressed. 2) To see if any key is pressed, the columns are scanned over and over in an infinite loop until one of them has a 0 on it. Remember that the output latches connected to rows still have their initial zeros (provided in stage 1), making them grounded. After the key press detection, it waits 20ms for the bounce and then scans the columns again. This serves two functions: (a) it ensures that the first key press detection was not an erroneous one due to spike noise, and(b) the 20ms delay prevents the same key press from being interpreted as a multiple key press. If after the 20-ms delay the key is still pressed, it goes to the next stage to detect which row it belongs to; otherwise, it goes back into the loop to detect a real key press 3) To detect which row the key press belongs to, it grounds one row at a time, reading the columns each time. If it finds that all columns are high, this means that the key press cannot belong to that row; therefore, it grounds the next row and continues until it finds the row the key press belongs to. Upon finding the row that the key press belongs to, it sets up the starting address for the look-up table holding the scan codes (or the ASCII value) for that row and goes to the next stage to identify the key. 4) To identify the key press, it rotates the column bits, one bit at a time, into the carry flag and checks to see if it is low. Upon finding the zero, it pulls out the ASCII code for that key from the look-up table; Otherwise, it increments the pointer to point to the next element of the look-up table. While the key press detection is standard for all keyboards, the process for determining which key is pressed varies. The look-up table method shown in program can be modified to work with any matrix up to 8*8. There are IC chips such as National Semiconductors MM74C923 that incorporate keyboard scanning and decoding all in one chip. Such chips use combinations of counters and logic gates (No microcontroller).

S-ar putea să vă placă și