当前位置:网站首页>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();
}
}边栏推荐
- 数字孪生实际应用案例-风机篇
- MySQL - storage engine
- Explain STM32 startup file in detail
- Shadowless cloud desktop - online computer
- Build your own random wallpaper API for free
- Detailed explanation of C language pointer
- How to modify the file path of Jupiter notebook under miniconda
- The mutual realization of C L stack and queue in I
- Idea push project to code cloud
- Hdu1231 maximum continuous subsequence (divide and conquer or dynamic gauge or double pointer)
猜你喜欢
![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](/img/fe/fb6df31c78551d8908ba7964c16180.jpg)
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

Daily Practice:Codeforces Round #794 (Div. 2)(A~D)

How to modify the file path of Jupiter notebook under miniconda

2022 PMP project management examination agile knowledge points (7)

I 用c l 栈与队列的相互实现

mysql 盲注常见函数

QT small case "addition calculator"

(tool use) how to make the system automatically match and associate to database fields by importing MySQL from idea and writing SQL statements

Altium Designer 19.1.18 - 导入板框

The number of occurrences of numbers in the offer 56 array (XOR)
随机推荐
How to realize audit trail in particle counter software
Leetcode solution - number of islands
Oracle triggers and packages
Apple system optimization
Day08 ternary operator extension operator character connector symbol priority
What is Bezier curve? How to draw third-order Bezier curve with canvas?
Hdu1232 unimpeded project (and collection)
Today, share the wonderful and beautiful theme of idea + website address
Graduation thesis project local deployment practice
Practical application cases of digital Twins - fans
Play with grpc - go deep into concepts and principles
Threads and processes
Simple operation with independent keys (hey, a little fancy) (keil5)
I can't stand the common annotations of idea anymore
Altium Designer 19.1.18 - 导入板框
611. 有效三角形的个数
Shadowless cloud desktop - online computer
Explain STM32 startup file in detail
Deepin get file (folder) list
Explanation of parallel search set theory and code implementation