当前位置:网站首页>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();
}
}
边栏推荐
- Literacy Ethernet MII interface types Daquan MII, RMII, smii, gmii, rgmii, sgmii, XGMII, XAUI, rxaui
- I can't stand the common annotations of idea anymore
- 基于FPGA的一维卷积神经网络CNN的实现(八)激活层实现
- ORACLE CREATE SEQUENCE,ALTER SEQUENCE,DROP SEQUENCE
- 611. 有效三角形的个数
- M2dgr slam data set of multi-source and multi scene ground robot
- Energy conservation and creating energy gap
- The difference between new and malloc
- D2L installation
- Steps and FAQs of connecting windows Navicat to Alibaba cloud server MySQL
猜你喜欢
The problem of configuring opencv in qt5.13.2 is solved in detail
Steps and FAQs of connecting windows Navicat to Alibaba cloud server MySQL
Special training of C language array
Concurrent programming - how to interrupt / stop a running thread?
U-Boot初始化及工作流程分析
Altimeter data knowledge point 2
And let's play dynamic proxy (extreme depth version)
SOC_ SD_ DATA_ FSM
2022年PMP项目管理考试敏捷知识点(7)
逻辑结构与物理结构
随机推荐
【软件测试】06 -- 软件测试的基本流程
【idea】Could not autowire. No beans of xxx type found
Solve tensorfow GPU modulenotfounderror: no module named 'tensorflow_ core. estimator‘
Ros2 - function package (VI)
Implementation of one-dimensional convolutional neural network CNN based on FPGA (VIII) implementation of activation layer
[software testing] 03 -- overview of software testing
Intelligent target detection 59 -- detailed explanation of pytoch focal loss and its implementation in yolov4
PowerManagerService(一)— 初始化
【Node】nvm 版本管理工具
The problem of configuring opencv in qt5.13.2 is solved in detail
逻辑结构与物理结构
SOC_SD_CMD_FSM
Ros2 - node (VII)
Concurrent programming - how to interrupt / stop a running thread?
Database SQL practice 3. Find the current salary details of the current leaders of each department and their corresponding department number Dept_ no
Batch convert txt to excel format
[vscode] prohibit the pylance plug-in from automatically adding import
Matrix and TMB package version issues in R
Unconventional ending disconnected from the target VM, address: '127.0.0.1:62635', transport: 'socket‘
Typescript get timestamp