立即注册 登录
返回首页

uid:316067的个人空间

日志

程序

已有 639 次阅读2018-4-25 11:27

#include<reg52.h>

#define uint unsigned int

#define uchar unsigned char


sbit duanx = P2^6;

sbit weix = P2^7;

uchar  key, k_tmp, view;


uchar show[] = {

    0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,

    0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71,0x40};


void keyscan(void)

{

    key = 16;  

    P3 = 0xf0;  k_tmp = P3 & 0xf0;

    if     (k_tmp == 0x70) key = 0; 

    else if(k_tmp == 0xb0) key = 1; 

    else if(k_tmp == 0xd0) key = 2;

    else if(k_tmp == 0xe0) key = 3;

    P3 = 0x0f;  k_tmp = P3 & 0x0f;

    if     (k_tmp == 0x07) key = key + 12; 

    else if(k_tmp == 0x0b) key = key + 8; 

    else if(k_tmp == 0x0d) key = key + 4; 

    else if(k_tmp == 0x0e) key = key + 0;


    view = show[key];


}


void display(uchar view)

{

    P0 = view; duanx = 1; duanx = 0;

    P0 = 0xfe; weix = 1;  weix = 0;

}


main()

{

    while(1) {

      keyscan();

      display(view);

    }

}



路过

鸡蛋

鲜花

握手

雷人

评论 (0 个评论)

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

返回顶部