当前位置:网站首页>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();
}
}
边栏推荐
- [vscode] prohibit the pylance plug-in from automatically adding import
- Ros2 - workspace (V)
- 基于Cortex-M3、M4的GPIO口位带操作宏定义(可总线输入输出,可用于STM32、ADuCM4050等)
- What is sodium hydroxide?
- [framework] multi learner
- C#学习笔记
- SD_ CMD_ SEND_ SHIFT_ REGISTER
- [idea] efficient plug-in save actions to improve your work efficiency
- 【软件测试】06 -- 软件测试的基本流程
- Qu'est - ce que l'hydroxyde de sodium?
猜你喜欢
Ros2 - first acquaintance with ros2 (I)
Negative number storage and type conversion in programs
Docker installs MySQL and uses Navicat to connect
剑指 Offer 56 数组中数字出现的次数(异或)
M2dgr slam data set of multi-source and multi scene ground robot
Ros2 topic (VIII)
Ros2 - function package (VI)
【无标题】
一文揭开,测试外包公司的真实情况
(tool use) how to make the system automatically match and associate to database fields by importing MySQL from idea and writing SQL statements
随机推荐
Executealways of unity is replacing executeineditmode
Ros2 - node (VII)
611. 有效三角形的个数
U-Boot初始化及工作流程分析
DataGrid offline installation of database driver
PHY drive commissioning --- mdio/mdc interface Clause 22 and 45 (I)
window navicat连接阿里云服务器mysql步骤及常见问题
HDU1232 畅通工程(并查集)
1290_FreeRTOS中prvTaskIsTaskSuspended()接口实现分析
[solved] there is something wrong with the image
并查集理论讲解和代码实现
Word import literature -mendeley
SOC_ SD_ CMD_ FSM
Binary search (half search)
SOC_SD_DATA_FSM
2022.06.27_每日一题
C#学习笔记
Qu'est - ce que l'hydroxyde de sodium?
Steps and FAQs of connecting windows Navicat to Alibaba cloud server MySQL
Concurrent programming - how to interrupt / stop a running thread?