当前位置:网站首页>Simple operation with independent keys (hey, a little fancy) (keil5)
Simple operation with independent keys (hey, a little fancy) (keil5)
2022-07-05 07:18:00 【After reading thousands of books, you can pick them up and put 】
Just got a brief understanding
sbit Definition *** One pin ***
sfr Definition *** A parallel port ***( Such as P2 Calculate a parallel port , Yes 8 One pin )
#define It's equivalent to changing names ,( Of course, self understanding , I don't know how to say it in technical terms ) For example, this string of code ***P2=0X8f&(P2|0xe0);// open y4 Latch ***, If you don't want to play so long next , Then you can ***#define Y4 P2=0X8f&(P2|0xe0);*** such , Next, you can write ***Y4;*** Just fine . All in all #define Pins and parallel ports cannot be defined .
#include <STC15F2K60S2.H>
sbit s7 = P3^0;// Definition P30 Pin , It can also be used directly P30
sbit s6 = P3^1;// Definition P31 Pin , It can also be used directly P31
/***************************************************/
void initsystem(unsigned char i)// initialization
{
switch(i)
{
case 4:
P2=0X8f&(P2|0xe0);// open y4 Latch
break;
case 5:
P2=0xbf&(P2|0xe0);// open y5 Latch
break;
case 6:
P2=0xdf&(P2|0xe0);// open y6 Latch
break;
case 7:
P2=0xff&(P2|0xe0);// open y7 Latch
break;
case 0:
P2=0x1f&(P2|0xe0);// Close the latch (y4,y5,y6,y7)
break;
}
}
/***********************************************/
void led_control(unsigned char n,unsigned char q)// Control lights (p0 End , Latch )
{
initsystem(q);
P0 = n;
}
/*******************************************/
void Delay (unsigned int t)// Time delay
{
while(t--);
while(t--);
}
/********************************************/
void LED_Running ()// Running lights
{
unsigned char i;
for (i=0;i<3;i++)// All lights are on and off 3 Time
{
led_control(0x00,4);
Delay (60000);
led_control(0xff,4);
Delay (60000);
}
for(i=1;i<8;i++)// The lights come on in turn
{
led_control(0xff<<i,4);
Delay(60000);
}
for(i=1;i<8;i++)// The lights go out in turn
{
led_control(~(0xff<<i),4);
Delay(60000);
}
}
/**********************************************/
void LED_1()// Interval flashing light
{
led_control(0xaa,4);
Delay (10000);
led_control(0x55,4);
Delay (10000);
}
/*********************************************************/
void key_alone()// Press s7 Execute the running light , Press s6 Perform interval flashing
{
if(s7==0)// or P30==0
Delay(60000);
if(s7==0)// or P30==0
{
LED_Running ();
}
if(s7==1)// or P30==1
{
led_control(0xff,4);
}
/**********************************************/
if(s6==0)// or P31==0
Delay(60000);
if(P31==0)// or P31==0
{
LED_1();
}
if(s6==1)// or P31==1
{
led_control(0xff,4);
}
}
/***************************************************/
void main()// The main function
{
led_control(0Xff,4);initsystem(0);// initialization
led_control(0x00,5);initsystem(0);// initialization
while(1)
{
key_alone();
}
}
边栏推荐
- 1290_FreeRTOS中prvTaskIsTaskSuspended()接口实现分析
- MySQL setting trigger problem
- [software testing] 02 -- software defect management
- Anaconda navigator click open no response, can not start error prompt attributeerror: 'STR' object has no attribute 'get‘
- Negative number storage and type conversion in programs
- PHY drive commissioning --- mdio/mdc interface Clause 22 and 45 (I)
- SOC_ SD_ DATA_ FSM
- 【Node】npm、yarn、pnpm 区别
- 第 2 章:小试牛刀,实现一个简单的Bean容器
- D2L installation
猜你喜欢

Brief description of inux camera (Mipi interface)

SOC_SD_CMD_FSM

Ethtool principle introduction and troubleshooting ideas for network card packet loss (with ethtool source code download)

Three body goal management notes
![[vscode] prohibit the pylance plug-in from automatically adding import](/img/a7/d96c0c4739ff68356c15bafbbb1328.jpg)
[vscode] prohibit the pylance plug-in from automatically adding import

Solve tensorfow GPU modulenotfounderror: no module named 'tensorflow_ core. estimator‘

第 2 章:小试牛刀,实现一个简单的Bean容器

Special training of C language array

Intelligent target detection 59 -- detailed explanation of pytoch focal loss and its implementation in yolov4
![[idea] efficient plug-in save actions to improve your work efficiency](/img/6e/49037333964865d9900ddf5698f7e6.jpg)
[idea] efficient plug-in save actions to improve your work efficiency
随机推荐
What if the DataGrid cannot see the table after connecting to the database
氢氧化钠是什么?
[vscode] prohibit the pylance plug-in from automatically adding import
Tshydro tool
list. files: List the Files in a Directory/Folder
Concurrent programming - deadlock troubleshooting and handling
剑指 Offer 56 数组中数字出现的次数(异或)
SD_ CMD_ RECEIVE_ SHIFT_ REGISTER
逻辑结构与物理结构
Logical structure and physical structure
(top) pretty girl binary color code portal
ModuleNotFoundError: No module named ‘picamera‘
ImportError: No module named ‘Tkinter‘
[software testing] 02 -- software defect management
HDU1231 最大连续子序列(分治or动规or双指针)
Negative number storage and type conversion in programs
PowerManagerService(一)— 初始化
(tool use) how to make the system automatically match and associate to database fields by importing MySQL from idea and writing SQL statements
PHY drive commissioning - phy controller drive (II)
D2L installation