当前位置:网站首页>Scm-05 basis of independent keyboard
Scm-05 basis of independent keyboard
2022-07-05 07:41:00 【LCH Nan'an】
subject :
Circuit diagram : Download address Blue Bridge Cup MCU simulation schematic diagram .pdsprj- Handout document resources -CSDN library
Code :
# include <reg52.h>
sbit HC138_C = P2^7;
sbit HC138_B = P2^6;
sbit HC138_A = P2^5;
// LED
sbit L1 = P0^0;
sbit L2 = P0^1;
sbit L3 = P0^2;
sbit L4 = P0^3;
sbit L5 = P0^4;
sbit L6 = P0^5;
// Independent keyboard
sbit S7 = P3^0;
sbit S6 = P3^1;
sbit S5 = P3^2;
sbit S4 = P3^3;
void DelayKey(unsigned char t)
{
while(t--);
}
void SwitchHC138(unsigned char channel)
{
switch(channel)
{
case 4:
HC138_C = 1;
HC138_B = 0;
HC138_A = 0;
break;
case 5:
HC138_C = 1;
HC138_B = 0;
HC138_A = 1;
break;
case 6:
HC138_C = 1;
HC138_B = 1;
HC138_A = 0;
break;
case 7:
HC138_C = 1;
HC138_B = 1;
HC138_A = 1;
break;
}
}
void ScanKeys_Alone()
{
if(S7 == 0)
{
DelayKey(100);
if(S7 == 0)
{
L1 = 0;
while(S7 == 0);
L1 = 1;
}
}
if(S6 == 0)
{
DelayKey(100);
if(S6 == 0)
{
L2 = 0;
while(S6 == 0);
L2 = 1;
}
}
if(S5 == 0)
{
DelayKey(100);
if(S5 == 0)
{
L3 = 0;
while(S5 == 0);
L3 = 1;
}
}
if(S4 == 0)
{
DelayKey(100);
if(S4 == 0)
{
L4 = 0;
while(S4 == 0);
L4 = 1;
}
}
}
void Init()
{
SwitchHC138(7);
P0=0x00;
SwitchHC138(5);
P0=0x00;
SwitchHC138(4);
P0=0xff;
}
void main()
{
Init();
while(1)
{
ScanKeys_Alone();
}
}
边栏推荐
- Oracle-触发器和程序包
- Basic series of SHEL script (III) for while loop
- Day07 type of mathematical operator automatic conversion relational operator bitwise operator blind date math
- STM32 learning method
- Today, share the wonderful and beautiful theme of idea + website address
- 611. 有效三角形的个数
- cygwin
- 行测--资料分析--fb--高照老师
- Typecho adds Baidu collection (automatic API submission plug-in and crawler protocol)
- Idea shortcut key
猜你喜欢
CADD course learning (6) -- obtain the existing virtual compound library (drugbank, zinc)
MySQL - storage engine
The mutual realization of C L stack and queue in I
Openxlsx field reading problem
mysql 盲注常见函数
Graduation thesis project local deployment practice
Build your own random wallpaper API for free
Nombre - 1. Création de tableaux
611. Number of effective triangles
Ugnx12.0 initialization crash, initialization error (-15)
随机推荐
通过sql语句统计特定字段出现次数并排序
Butterfly theme beautification - Page frosted glass effect
Self summary of college life - freshman
MySQL - storage engine
[idea] common shortcut keys
Day09 how to create packages import package naming conventions Alibaba Development Manual
[neo4j] common operations of neo4j cypher and py2neo
STM32 knowledge points
UE5热更新-远端服务器自动下载和版本检测(SimpleHotUpdate)
Idea common settings
Idea shortcut key
Apple system shortcut key usage
Mouse click fireworks explosion effect
Play with grpc - go deep into concepts and principles
Anaconda pyhton multi version switching
Opendrive ramp
How to modify the file path of Jupiter notebook under miniconda
assert_ Usage of param function
Calibre garbled
CADD course learning (5) -- Construction of chemosynthesis structure with known target (ChemDraw)