51 MCU matrix button circuit diagram + program

Publisher:颐真阁Latest update time:2014-12-30 Source: 51hei Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

The following is the circuit diagram of the digital tube part: The following is the circuit diagram of the matrix keyboard part: The C51 microcontroller program is as follows:




#include
#define uchar unsigned char
#define uint  unsigned int
//Segment code of digital tube
uchar table[16] = {0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};
fly seg[4]={0xfe,0xfd,0xfb,0xf7};
this is flying;
 
void Delay_1ms(uint i) //1ms delay
{
fly x,j;
for(j=0;j
for(x=0;x<=148;x++);
}
 
void keyboard()
{
fly x,y,i;
for(y=0;y<4;y++)
{
P1=seg[y];
if((P1&0xf0)!=0xf0)
{
Delay_1ms(5);
if((P1&0xf0)!=0xf0)
{
x=P1&0XF0;
x=(x>>4)|0xf0;
for(i=0;i<4;i++)
{
if(x==seg[i])
{
x=i;
shu=4*y+x+1;
}
}
}
}
}
}
 
void segdisplay(float i)
{
P0 = 0; //Blanking      
P2 = 6; //The 7th digital tube display
P0 = table[(i / 10)%10];     //Get the tens digit of i here
Delay_1ms(5);         //Display the next number after 0.5 seconds delay
P0 = 0;         //Blank
P2 = 7; //The 8th digital tube display
P0 = table[i % 10];           //Get the unit digit of i here
Delay_1ms(5);
P0=0;
}
 
void main()
{
this = 0;
while(1)
{
keyboard();
segdisplay(shu);
}
}
Reference address:51 MCU matrix button circuit diagram + program

Previous article:Design of image-based electronic police system based on single chip microcomputer
Next article:Single chip microcomputer timer T0 counts seconds C51 program + circuit

Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号