当前位置:网站首页>Blue Bridge Cup Guoxin Changtian single chip microcomputer -- led lamp module (V)
Blue Bridge Cup Guoxin Changtian single chip microcomputer -- led lamp module (V)
2022-07-03 21:52:00 【C don't laugh】
LED Etc
The whole idea
adopt 74HC138 Chip and 74HC02 Chip input high and low level , To control Y4C by 1 or 0. When Y4C by 1 when , To be approved P0 Port to control LED The light goes on and off . When Y4C by 0 when , beyond control LED The light goes on and off . Such as : Make P27 by 1、P26 by 0、P25 by 0, The output Y4 by 0, Re pass 74HC02 chip , take Y4 by 0 Input , be Y4C Output is 1. Re pass P0 by 0xfe namely Q8-Q1, by 1111 1110, control L1 bright . Can also order P0 by 0x00 namely Q8-Q1, by 0000 0000, control L1~L8 On at the same time .
LED Control step decomposition :
Step one :
from CT107D Found in the schematic diagram of single chip microcomputer comprehensive training platform LED modular
According to the schematic diagram , We can know , The anode of this group of light-emitting diodes , A high level has been given , So as long as we give a low level at the cathode , You can make the diode light up .
Did you learn 51 Our friends all know , To give a low level , We just need to make IO The mouth is 0, That's all right. . namely
P0 = 0x00; // Light all LED
But what? , This board , You directly ordered P0 The mouth is 0, It cannot be lit IO Oral . stay P0 There is a chip between the port and the LED 74HC573( Latch ). Module detailed view Blue Bridge Cup Guoxin Changtian MCU – A detailed explanation of the schematic diagram ( Four )
Step two :
There is... On the board 4 slice 74HC573 chip , Enable one Y4C port ( Setting high level can control the chip ), utilize 138 The decoder sets the high and low level of the port .
138 The function of the decoder here is to use P25,P26,P27, That is to say P2 The upper three digits of the mouth control the selected position .
Can make P27-p25 Zero clearing , Reorientation Y4C operation
P2 = P2 & 0x1F | 0x80; //P27-p25 Zero clearing , Reorientation Y4C
P2 &= 0x1F; //P27-p25 Zero clearing
IO Programming lights up LED The core code is as follows :
P2 = ((P2&0x1F)|0x80);
P0 = 0x00; // Light all LED
P2 = P2 & 0x1F;
Case study :
LED flashing
#include "reg52.h" // Definition 51 MCU special function register
// The time delay function
void delay(void)
{
unsigned char i,j,k;
for(i=0; i<20; i++)
{
for(j=0; j<20; j++)
{
for(k=0; k<248; k++);
}
}
}
// The main function
void main(void)
{
while(1)
{
P2 = ((P2&0x1f)|0x80);
P0 = 0xff; //LED Extinguish
P2 &= 0x1f;
delay();
P2 = ((P2&0x1f)|0x80);
P0 = 0x00; //LED Lighten up
P2 &= 0x1f;
delay();
}
}
边栏推荐
- Market layout planning and latest dynamic analysis report of China's smart public security industry Ⓕ 2022 ~ 2028
- Global and Chinese market of recycled yarn 2022-2028: Research Report on technology, participants, trends, market size and share
- DOM light switch case
- Quickly distinguish slices and arrays
- Functions and differences between static and Const
- What is the content of the securities practice examination?
- Getting started with postman -- built-in dynamic parameters, custom parameters and assertions
- Report on the current situation and development trend of ethoxylated sodium alkyl sulfate industry in the world and China Ⓞ 2022 ~ 2027
- 使用dnSpy对无源码EXE或DLL进行反编译并且修改
- 2022 safety officer-b certificate examination summary and safety officer-b certificate simulation test questions
猜你喜欢
Mysql - - Index
MySQL - index
Monkey/ auto traverse test, integrate screen recording requirements
Yiwen teaches you how to choose your own NFT trading market
gslb(global server load balance)技术的一点理解
Imitation Netease cloud music applet
MySQL——JDBC
常用sql集合
Décompiler et modifier un exe ou une DLL non source en utilisant dnspy
On my first day at work, this API timeout optimization put me down!
随机推荐
Qualcomm platform WiFi -- P2P issue
鹏城杯 WEB_WP
请教大家一个问题,用人用过flink sql的异步io关联MySQL中的维表吗?我按照官网设置了各种
MySQL - database backup
Go language slice interview real question 7 consecutive questions
Collection | pytoch common loss function disassembly
2022 safety officer-b certificate examination summary and safety officer-b certificate simulation test questions
Investment analysis and prospect trend prediction report of China's boron nitride industry Ⓨ 2022 ~ 2028
Base ring tree Cartesian tree
TiDB 之 TiCDC6.0 初体验
Baohong industry | good habits that Internet finance needs to develop
Pengcheng cup Web_ WP
Station B, dark horse programmer, employee management system, access conflict related (there is an unhandled exception at 0x00007ff633a4c54d (in employee management system.Exe): 0xc0000005: read locat
4. Data splitting of Flink real-time project
油猴插件
MySQL——索引
2022-02-15 Daily: 2022 AAAI fellow release
gslb(global server load balance)技術的一點理解
The latest analysis of crane driver (limited to bridge crane) in 2022 and the test questions and analysis of crane driver (limited to bridge crane)
常用sql集合