51单片机矩阵按键源码

  • s1_238429
    了解作者
  • 103.3KB
    文件大小
  • zip
    文件格式
  • 0
    收藏次数
  • VIP专享
    资源类型
  • 0
    下载次数
  • 2022-06-03 06:44
    上传日期
51单片机矩阵按键源码
矩阵按键.zip
  • 矩阵按键
  • 计算器
  • 按键按下数码管子+1
  • 2消抖
  • jzaj.plg
    9.8KB
  • jzaj.LST
    3.3KB
  • STARTUP.LST
    13.7KB
  • jzaj.lnp
    56B
  • jzaj.c
    1.1KB
  • jzaj.M51
    6.8KB
  • jzaj.OBJ
    3.3KB
  • jzaj_uvopt.bak
    55.4KB
  • jzaj.hex
    888B
  • STARTUP.A51
    6.2KB
  • jzaj.uvproj
    13.1KB
  • STARTUP.OBJ
    749B
  • jzaj.uvopt
    55.5KB
  • jzaj
    3.6KB
  • jzaj_uvproj.bak
    0B
  • 1抖动
  • jzaj.plg
    1.1KB
  • jzaj.LST
    2.6KB
  • STARTUP.LST
    13.7KB
  • jzaj.lnp
    56B
  • jzaj.c
    800B
  • jzaj.M51
    5.5KB
  • jzaj.OBJ
    2.3KB
  • jzaj_uvopt.bak
    55.9KB
  • jzaj.hex
    711B
  • STARTUP.A51
    6.2KB
  • jzaj.uvproj
    13.1KB
  • STARTUP.OBJ
    749B
  • jzaj.uvopt
    55.4KB
  • jzaj
    2.8KB
  • jzaj_uvproj.bak
    0B
  • 消抖矩阵
  • jzaj.plg
    186B
  • jzaj.LST
    5.4KB
  • STARTUP.LST
    13.7KB
  • jzaj.lnp
    56B
  • jzaj.c
    2.2KB
  • jzaj.M51
    8KB
  • jzaj.OBJ
    5.4KB
  • jzaj_uvopt.bak
    55.4KB
  • jzaj.hex
    2.4KB
  • STARTUP.A51
    6.2KB
  • jzaj.uvproj
    13.1KB
  • STARTUP.OBJ
    749B
  • jzaj.uvopt
    55.1KB
  • jzaj
    5.7KB
  • jzaj_uvproj.bak
    0B
  • 按键点亮4个LED
  • jzaj.plg
    173B
  • jzaj.LST
    1.3KB
  • STARTUP.LST
    13.7KB
  • jzaj.lnp
    56B
  • jzaj.c
    292B
  • jzaj.M51
    3.9KB
  • jzaj.OBJ
    1.4KB
  • jzaj_uvopt.bak
    55.9KB
  • jzaj.hex
    137B
  • STARTUP.A51
    6.2KB
  • jzaj.uvproj
    13.1KB
  • STARTUP.OBJ
    749B
  • jzaj.uvopt
    55.9KB
  • jzaj
    1.9KB
  • jzaj_uvproj.bak
    0B
内容介绍
#include<reg52.h> sbit LED1 = P1^0; sbit LED2 = P1^1; sbit LED3 = P1^2; sbit LED4 = P1^3; sbit dula=P2^6; //段选信号的锁存器控制 sbit wela=P2^7; //位选信号的锁存器控制 sbit KEY_IN_1 = P3^4; sbit KEY_IN_2 = P3^5; sbit KEY_IN_3 = P3^6; sbit KEY_IN_4 = P3^7; sbit KEY_OUT_1 = P3^0; sbit KEY_OUT_2 = P3^1; sbit KEY_OUT_3 = P3^2; sbit KEY_OUT_4 = P3^3; unsigned char LedChar[]={0X3F,0X06,0X5B,0X4F,0X66,0X6D,0X7D,0X07 ,0X7F,0X6F,0X77,0X7C,0X39,0X5E,0X79,0X71}; //数码管增值表 unsigned char keysta[4][4] = {{1,1,1,1},{1,1,1,1},{1,1,1,1},{1,1,1,1}}; //按键消抖动数组 void main() { unsigned char cnt = 0; unsigned char i, j = 0; unsigned char backup [4][4] = {{1,1,1,1},{1,1,1,1},{1,1,1,1},{1,1,1,1}}; EA = 1 ; TH0 = 0XF8; TL0 = 0XCD; ET0 = 1; ET0 = 1; TR0 = 1; P3=0XFE; wela=1; P0=0xDF; wela=0; dula=1; P0= LedChar[cnt] ; dula=1; while(1) { for (i=0; i<4; i++) { for (j=0; j<4; j++) { if(backup[i][j] != keysta[i][j]) { if(backup[j][j] == 0) { P0 = LedChar [i*4+j]; } backup[i][i] = keysta[i][j]; } } } } } void InterruptTimer0() interrupt 1 { static unsigned char keyout = 0; unsigned char i = 0; static unsigned char keybuf[4][4] = { {0xFF,0xFF,0xFF,0xFF,}, {0xFF,0xFF,0xFF,0xFF,}, {0xFF,0xFF,0xFF,0xFF,}, {0xFF,0xFF,0xFF,0xFF,} }; TH0 = 0xFC; TL0 = 0X67; keybuf[keyout][0] = (keybuf [keyout][0] <<1) | KEY_IN_1; keybuf[keyout][1] = (keybuf [keyout][1] <<1) | KEY_IN_2; keybuf[keyout][2] = (keybuf [keyout][2] <<1) | KEY_IN_3; keybuf[keyout][3] = (keybuf [keyout][3] <<1) | KEY_IN_4; for(i=0; i<4; i++) { if((keybuf[keyout][i] & 0x0F) == 0X00) { keysta[keyout][i] = 0; } else if ((keybuf[keyout][i] & 0x0F) == 0X0F) { keysta[keyout][i] = 1; } } keyout++; keyout = keyout & 0x03; switch(keyout) { case 0 : KEY_OUT_4 = 1;KEY_OUT_1 = 0;break; case 1 : KEY_OUT_1 = 1;KEY_OUT_2 = 0;break; case 2 : KEY_OUT_2 = 1;KEY_OUT_3 = 0;break; case 3 : KEY_OUT_3 = 1;KEY_OUT_4 = 0;break; default: break; } }
评论
    相关推荐