当前位置:网站首页>Blue Bridge Cup SCM module code (LED) (code + comments)
Blue Bridge Cup SCM module code (LED) (code + comments)
2022-06-25 06:44:00 【tuygre】
#include "STC15F2K60S2.H"
/* The header file ; comparison reg52.h Omit sbit The use of equal functions , It is more suitable for single chip computers in competitions , Readers can use STC-ISP Installation */
typedef unsigned int u16;
typedef unsigned char u8;.
/* Redefine the variable name , Convenient programming ; Unsigned integer is 2 byte , from 16 position 2 Composition of binary system , The unsigned character is 1 byte , from 8 Bit binary composition */
void close()
{
P0=0;
/*P0=0000 0000*/
P2=P2&0X1F|0XA0;
/* Use binary and or operations , We will clear the top three first , And then set the senior three to 101,101 The decimal system of is 5, So the decoder 74HC138 take Y5 Turn to low level , NOR gate calculation Y5C=0+0=0 Non - =1, Open the latch ,P0=0 The signal is transmitted to the right , because ULN2003 There is a non gate inside , therefore BUZZER The input is VCC, The buzzer doesn't sound */
P2=P2&0X1F;
/* Enable the decoder to Y0 Set to low level , This single chip microcomputer Y0 In the air , So it will not affect the application of any other program , Play a protective role , The next three lines are similar , Do not repeat */
P0=0XFF;
P2=P2&0X1F|0X80;
P2=P2&0X1F;
}
/* This function turns off peripheral functions , When the MCU is reset , Default LED All the lights are on , Buzzer ring , So the peripheral function is closed to extinguish LED, Turn off the buzzer , Achieve the user's desired initialization state */
void lighten(u8 led)
{
P0=~led;
/* In the schematic diagram , According to the unidirectional conductivity of the diode ,P0 One of them is 0 when , Corresponding LED Light on ; Negation makes the input P0 Some one is 1 when , Corresponding light is on , Make programming easier to understand , Of course, it is also possible not to take the opposite */
P2=P2&0X1F|0X8F;
P2=P2&0X1F;
}
/* This function is lit LED function */
void delay(u8 num)
{
u16 i;
while(num--)
for(i=0;i<=1000;i++);
}
/* The time delay function , This section is used to extend the time of each state ; The function run time can be determined by the current crystal oscillator 、 Instruction type and number of cycles , But it is not necessary to ,STC-ISP There is already a computing function , And there is a timer module in the MCU , This function is used here only to show the phenomenon */
void main()
{
u8 num,time;
close();
while(1)
{
for(num=1;num<=5;num++)
/* By changing num It's not hard to see : The delay function changes in multiples of time ,num The change is the time when the light is on and off in each cycle , But even if delay Time has multiplied , Still too fast for the human eye , therefore num Different , What we feel is the brightness of the light */
for(time=0;time<100;time++)
/* loop 100 The second is to ensure that the time for each brightness is not too short , Easy to observe */
{
lighten(0);
delay(5-num);
lighten(0xff);
delay(num);
}
}
}
/* This code achieves the effect of gradient brightness , Readers can improve it , Achieve a gorgeous effect .*/Official schematic diagram , The download address of the user manual is as follows :
link :https://pan.baidu.com/s/1y8lRYHxLKojL4_r0PZPYRw
Extraction code :19so
Note cannot insert picture , Relevant information readers themselves look for in the folder .
Study notes for undergraduate students of Nanjing University of Information Engineering , For your reference .
If there is a mistake , contact QQ3182097183.
边栏推荐
- After unplugging the network cable, does the original TCP connection still exist?
- 3dmax软件的制作木桶过程:三步流程
- Understand what MSS is
- Entry level use of flask
- Is the number of indexes in a table the more the better?
- Leetcode 2163. Minimum difference of sum after element deletion
- DataX tutorial (10) - hot plug principle of dataX plug-in
- 2022 AI trend 8 forecast!
- Record of friend guide
- Wan Yin revealed that he was rejected by MIT in this way: "the department doesn't like you". He confronted the principal and realized
猜你喜欢

Navicat prevent new query from being deleted by mistake

We cannot activate inspection type for article master in transaction code MM41?

Self adjustment process of MySQL index tree when adding data

原子Alpha开发板--SD卡和emmc烧录工具

【ROS2】为什么要使用ROS2?《ROS2系统特性介绍》

百度地图——入门教程

Ht513 I2S input 2.8W mono class D audio power amplifier IC

Large funds support ecological construction, and Plato farm builds a real meta universe with Dao as its governance

keil debug查看变量提示not in scope

直接选择排序和快速排序
随机推荐
Atomic alpha development board -- SD card and EMMC burning tool
Cloning and importing DOM nodes
Leetcode 2163. Minimum difference of sum after element deletion
Ht81293 built in adaptive dynamic boost 20W mono class D power amplifier IC solution
Ht8513 single lithium battery power supply with built-in Dynamic Synchronous Boost 5W mono audio power amplifier IC solution
Flask 的入门级使用
Why did Yanjing Beer come here?
[no title] dream notes 2022-02-20
How to configure log4j to only keep log files for the last seven days?
Wan Yin revealed that he was rejected by MIT in this way: "the department doesn't like you". He confronted the principal and realized
Ctfhub web - divulgation d'informations - traversée du Répertoire
fastadmin 联级清空数据
With a younger brother OCR, say no to various types of verification codes!
How to find happiness in programming and get lasting motivation?
了解zbrush雕刻软件,以及游戏建模的分析
Brief introduction and use of JSON
Controlling volume mixer
joda.time获取日期总结
cos(a+b)=cosa*cosb-sina*sinb的推导过程
Unity get resource path