当前位置:网站首页>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();
}
}
边栏推荐
- Chapter 2: try to implement a simple bean container
- PowerManagerService(一)— 初始化
- [idea] efficient plug-in save actions to improve your work efficiency
- 【obs】x264编码:“buffer_size“
- arcgis_ spatialjoin
- Ros2 - function package (VI)
- [OBS] x264 Code: "buffer_size“
- HDU1232 畅通工程(并查集)
- 目标检测系列——Faster R-CNN原理详解
- postmessage通信
猜你喜欢
Steps and FAQs of connecting windows Navicat to Alibaba cloud server MySQL
SOC_SD_DATA_FSM
An article was opened to test the real situation of outsourcing companies
Mathematical analysis_ Notes_ Chapter 8: multiple integral
611. 有效三角形的个数
PostMessage communication
睿智的目标检测59——Pytorch Focal loss详解与在YoloV4当中的实现
Ros2 - first acquaintance with ros2 (I)
Mipi interface, DVP interface and CSI interface of camera
Concurrent programming - deadlock troubleshooting and handling
随机推荐
Concurrent programming - deadlock troubleshooting and handling
Ros2 - first acquaintance with ros2 (I)
Mid 2022 documentary -- the experience of an ordinary person
程序中的负数存储及类型转换
M2DGR 多源多场景 地面机器人SLAM数据集
Ethtool principle introduction and troubleshooting ideas for network card packet loss (with ethtool source code download)
[software testing] 06 -- basic process of software testing
Using GEE plug-in in QGIS
Hdu1232 unimpeded project (and collection)
And play the little chestnut of dynamic agent
Jenkins reported an error. Illegal character: '\ufeff'. Class, interface or enum are required
你心目中的数据分析 Top 1 选 Pandas 还是选 SQL?
纯碱是做什么的?
【软件测试】05 -- 软件测试的原则
Do you choose pandas or SQL for the top 1 of data analysis in your mind?
Lexin interview process
Ros2 - function package (VI)
Brief description of inux camera (Mipi interface)
2022.06.27_ One question per day
Binary search (half search)