当前位置:网站首页>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();
}
}
边栏推荐
- Apple system shortcut key usage
- [idea] common shortcut keys
- Readme, self study record
- Ue5 hot update - remote server automatic download and version detection (simplehotupdate)
- Matrix keyboard scan (keil5)
- Nombre - 1. Création de tableaux
- Process (P) runs, and idle is different from pycharm
- The folder directly enters CMD mode, with the same folder location
- Altium Designer 19.1.18 - 清除测量距离产生的信息
- [untitled]
猜你喜欢
Thunderbird tutorial \ easy to use mail client
Idea common settings
When jupyter notebook is encountered, erroe appears in the name and is not output after running, but an empty line of code is added downward, and [] is empty
Basic series of SHEL script (III) for while loop
Light up the running light, rough notes for beginners (1)
Self summary of college life - freshman
CADD课程学习(6)-- 获得已有的虚拟化合物库(Drugbank、ZINC)
A complete set of indicators for the 10000 class clean room of electronic semiconductors
Unforgettable summary of 2021
借助 Navicat for MySQL 软件 把 不同或者相同数据库链接中的某数据库表数据 复制到 另一个数据库表中
随机推荐
Cookie operation
Shadowless cloud desktop - online computer
Matrix keyboard scan (keil5)
Nombre - 1. Création de tableaux
CADD课程学习(5)-- 构建靶点已知的化合结构(ChemDraw)
Cygwin installation
Apple system optimization
Hdu1232 unimpeded project (and collection)
Latex notes
Rough notes of C language (1)
Day01 markdown log entry tips
Readme, self study record
Deepin, help ('command ') output saved to file
How to deal with excessive memory occupation of idea and Google browser
GBK error in web page Chinese display (print, etc.), solution
CADD course learning (5) -- Construction of chemosynthesis structure with known target (ChemDraw)
Day08 ternary operator extension operator character connector symbol priority
Function of static
selenium 元素定位
CADD课程学习(6)-- 获得已有的虚拟化合物库(Drugbank、ZINC)