Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

4*8 key matrix - need correction of diagram, module

Status
Not open for further replies.

arun_9998

Banned
Member level 2
Joined
Aug 25, 2008
Messages
53
Helped
11
Reputation
22
Reaction score
10
Trophy points
1,288
Location
india
Visit site
Activity points
0
4*8 key matrix help

have any tell me can i make 8*4 key matrix

#ifndef KBOARD_H
#define KBOARD_H

#include "reg51.h"
#include "Delay.h"
//#include "Lcd.h"
#include <intrins.h>
#include<stdio.h>

/*****************************************************************************
*
* Constant Definitions.
*
*****************************************************************************/

/**
* Hardware keyboard port assignment.
* Adjust \b KEYPORT to match hardware.
* \hideinitializer
*/
#define KEYPORT P0

/*
* idkey() return this when no key is pressed.
*/
#define NOKEY 32


/*****************************************************************************
*
* Public Function Prototypes.
*
*****************************************************************************/

//extern char _getkey(void); // defined in stdio.h

/**
* 4 x 8 keyboard initialisation function.
* \param -
* \return -
*/
extern void kboard_init(void);

#endif
******************************************************************************/

#include "Kboard.h"

/*****************************************************************************
*
* Global Variables
*
*****************************************************************************/
/*
* Keyboard scan row/ column output and input pattern codes.
*/
static const unsigned char code KEY_IO[32] = {0x70, 0xB0, 0xD0, 0xE0,
0x71, 0xB1, 0xD1, 0xE1,
0x72, 0xB2, 0xD2, 0xE2,
0x73, 0xB3, 0xD3, 0xE3,
0x74, 0xB4, 0xD4, 0XE4,
0x75, 0xB5, 0xD5, 0xE5,
0x76, 0xB6, 0xD6, 0xE6,
0x77, 0xB7, 0xD7, 0xE7};

/*
* Keyboard key position to ASCII representation codes.
*/
static const char code KEY_MAP[32] = {'1', '2', '3', '4',
'5', '6', '7', '8',
'9', 'A','B','C',
'D','E','F','G',
'H','I','J','K',
'L','M','N','O',
'P','Q','R','S',
'T','U','V','W' }; // CR BS

/*****************************************************************************
*
* Private Function Prototypes
*
*****************************************************************************/
static unsigned char kboard_makekey(void);
static void kboard_breakkey(void);
static unsigned char kboard_idkey(void);


/*****************************************************************************
*
* Private Function Implementation
*
*****************************************************************************/

/*****************************************************************************
*
* kboard_makekey()
*
*****************************************************************************/
static unsigned char kboard_makekey(void)
{
unsigned char key, newkey;

do
{
while((key = kboard_idkey()) == NOKEY);
#ifdef LCD_H
lcd_beep(5);
#endif
delay_ms(10);
} while((newkey = kboard_idkey()) != key);

return(key);
}

/*****************************************************************************
*
* kboard_breakkey()
*
*****************************************************************************/
static void kboard_breakkey(void)
{
do
{
while(kboard_idkey() != NOKEY);
delay_ms(10);
} while(kboard_idkey() != NOKEY);
}

/*****************************************************************************
*
* kboard_idkey()
*
*****************************************************************************/
static unsigned char kboard_idkey(void)
{
unsigned char key = 0xFF;
bit keyfound = 0;

do
{
key++;
KEYPORT &= 0xF0; // clear lower nibble
KEYPORT |= KEY_IO[key] & 0x0F; // output lower nibble
keyfound = ((KEYPORT & 0xF0) == (KEY_IO[key] & 0xF0));

} while((key < NOKEY) && (!keyfound));

return(key);
}


/*****************************************************************************
*
* Public Function Implementation
*
*****************************************************************************/

/*****************************************************************************
*
* kboard_init()
*
*****************************************************************************/
void kboard_init(void)
{
KEYPORT = 0xFF; // Set all bits as input
}

/*****************************************************************************
*
* _getkey()
*
*****************************************************************************/
char _getkey(void)
{
unsigned char key = NOKEY;

while(key == NOKEY)
{
key = kboard_makekey();
kboard_breakkey();
}

return (KEY_MAP[key]);
}
********************************************************************
********************************************************************
MAIN.C
****************************************************************************************************************************************
#include<reg51.h>
#include<stdio.h>
#include "Kboard.h"

void main()
{
unsigned int ch=0;
kboard_init();
while(1)
{
scanf("%d",&ch);
}
}
 

Re: 4*8 key matrix help

What is the question here ?

Did you make the circuit and is not working ?

What do you need to know ?
 

    arun_9998

    Points: 2
    Helpful Answer Positive Rating
Re: 4*8 key matrix help

i request please cheak this code and diagram is this work if not please correct this module and diagram
thanks for reply
 

Re: 4*8 key matrix help

HI

Add some pullup resistor for P0.4~P0.7

All the best

Bobi
 

Re: 4*8 key matrix help

hello sir,
this is not work when i press any key P0^0 goes 1 and P0^0-P0^4 goes 1 and progrem counter stop please simulate this code
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top