当前位置:网站首页>Matrix keyboard scan (keil5)
Matrix keyboard scan (keil5)
2022-07-05 07:18:00 【After reading thousands of books, you can pick them up and put 】
Copy and paste the kind that beginners don't need to use their brains
#include <STC15F2K60S2.H>
#include <intrins.h>
unsigned char code num[16]={
0xc0,0xcf,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x98,0x88,0x80,0xc6,0xc0,0x86,0x8e};//0123456789abcd
sbit R1 = P3^0;
sbit R2 = P3^1;
sbit R3 = P3^2;
sbit R4 = P3^3;
sbit C1 = P3^4;
sbit C2 = P3^5;
sbit C3 = P3^6;
sbit C4 = P3^7;
/***********************************************/
void initsystem(unsigned char i)
{
switch(i)
{
case 4:
P2=0X8f&(P2|0xe0);
break;
case 5:
P2=0xbf&(P2|0xe0);
break;
case 6:
P2=0xdf&(P2|0xe0);
break;
case 7:
P2=0xff&(P2|0xe0);
break;
case 0:
P2=0x1f&(P2|0xe0);
break;
}
}
/*****************************************************/
unsigned char s;
void SMG_Display()
{
initsystem(6);
P0=0x01;
initsystem(7);
P0=num[s];
}
void Delay100ms() //@11.0592MHz
{
unsigned char i, j, k;
_nop_();
_nop_();
i = 5;
j = 52;
k = 195;
do
{
do
{
while (--k);
} while (--j);
} while (--i);
}
/*****************************************************/
void key_s()
{
R1=0;
R2=R3=R4=1;
C1=C2=C3=C4=1;
if(C1==0)
{
Delay100ms();
if(C1==0)
{
s=0;
SMG_Display();// The nixie tube first displays 0
}
}
R1=0;
R2=R3=R4=1;
C1=C2=C3=C4=1;
if(C2==0)
{
Delay100ms();
if(C2==0)
{
s=1;
SMG_Display();// The nixie tube first displays 1
}
}
R1=0;
R2=R3=R4=1;
C1=C2=C3=C4=1;
if(C3==0)
{
Delay100ms();
if(C3==0)
{
s=2;
SMG_Display();// The nixie tube first displays 2
}
}
R1=0;
R2=R3=R4=1;
C1=C2=C3=C4=1;
if(C4==0)
{
Delay100ms();
if(C4==0)
{
s=3;
SMG_Display();// The nixie tube first displays 3
}
}
R2=0;
R1=R3=R4=1;
C1=C2=C3=C4=1;
if(C1==0)
{
Delay100ms();
if(C1==0)
{
s=4;
SMG_Display();// The nixie tube first displays 4
}
}
R2=0;
R1=R3=R4=1;
C1=C2=C3=C4=1;
if(C2==0)
{
Delay100ms();
if(C2==0)
{
s=5;
SMG_Display();// The nixie tube first displays 5
}
}
R2=0;
R1=R3=R4=1;
C1=C2=C3=C4=1;
if(C3==0)
{
Delay100ms();
if(C3==0)
{
s=6;
SMG_Display();// The nixie tube first displays 6
}
}
R2=0;
R1=R3=R4=1;
C1=C2=C3=C4=1;
if(C4==0)
{
Delay100ms();
if(C4==0)
{
s=7;
SMG_Display();// The nixie tube first displays 7
}
}
R3=0;
R1=R2=R4=1;
C1=C2=C3=C4=1;
if(C1==0)
{
Delay100ms();
if(C1==0)
{
s=8;
SMG_Display();// The nixie tube first displays 8
}
}
R3=0;
R1=R2=R4=1;
C1=C2=C3=C4=1;
if(C2==0)
{
Delay100ms();
if(C2==0)
{
s=9;
SMG_Display();// The nixie tube first displays 9
}
}
R3=0;
R1=R2=R4=1;
C1=C2=C3=C4=1;
if(C3==0)
{
Delay100ms();
if(C3==0)
{
s=10;
SMG_Display();// The nixie tube first displays 10
}
}
R3=0;
R1=R2=R4=1;
C1=C2=C3=C4=1;
if(C4==0)
{
Delay100ms();
if(C4==0)
{
s=11;
SMG_Display();// The nixie tube first displays 11
}
}
R4=0;
R1=R2=R3=1;
C1=C2=C3=C4=1;
if(C1==0)
{
Delay100ms();
if(C1==0)
{
s=12;
SMG_Display();// The nixie tube first displays 12
}
}
R4=0;
R1=R2=R3=1;
C1=C2=C3=C4=1;
if(C2==0)
{
Delay100ms();
if(C2==0)
{
s=13;
SMG_Display();// The nixie tube first displays 13
}
}
R4=0;
R1=R2=R3=1;
C1=C2=C3=C4=1;
if(C3==0)
{
Delay100ms();
if(C3==0)
{
s=14;
SMG_Display();// The nixie tube first displays 14
}
}
R4=0;
R1=R2=R3=1;
C1=C2=C3=C4=1;
if(C4==0)
{
Delay100ms();
if(C4==0)
{
s=15;
SMG_Display();// The nixie tube first displays 15
}
}
}
void main()
{
while(1)
{
key_s();
}
}
边栏推荐
- Steps and FAQs of connecting windows Navicat to Alibaba cloud server MySQL
- What is soda?
- [OBS] x264 Code: "buffer_size“
- Special training of C language array
- MySQL setting trigger problem
- Ros2 - node (VII)
- What if the DataGrid cannot see the table after connecting to the database
- 三体目标管理笔记
- Concurrent programming - how to interrupt / stop a running thread?
- mingling
猜你喜欢

docker安装mysql并使用navicat连接

目标检测系列——Faster R-CNN原理详解

Steps and FAQs of connecting windows Navicat to Alibaba cloud server MySQL

【Node】nvm 版本管理工具

Tshydro tool

What if the DataGrid cannot see the table after connecting to the database

三体目标管理笔记

Special training of C language array

Delayqueue usage and scenarios of delay queue

Word import literature -mendeley
随机推荐
[software testing] 04 -- software testing and software development
Unity UGUI不同的UI面板或者UI之间如何进行坐标匹配和变换
剑指 Offer 56 数组中数字出现的次数(异或)
Matrix and TMB package version issues in R
PostMessage communication
[idea] efficient plug-in save actions to improve your work efficiency
Database SQL practice 4. Find the last of employees in all assigned departments_ Name and first_ name
SOC_SD_DATA_FSM
What does soda ash do?
SD_ CMD_ SEND_ SHIFT_ REGISTER
HDU1232 畅通工程(并查集)
【软件测试】05 -- 软件测试的原则
Reading literature sorting 20220104
ORACLE CREATE SEQUENCE,ALTER SEQUENCE,DROP SEQUENCE
arcgis_ spatialjoin
Qu'est - ce que l'hydroxyde de sodium?
Mid 2022 documentary -- the experience of an ordinary person
氢氧化钠是什么?
(tool use) how to make the system automatically match and associate to database fields by importing MySQL from idea and writing SQL statements
Initialization of global and static variables