当前位置:网站首页>独立按键控制led
独立按键控制led
2022-07-30 05:46:00 【缘聚654】
今天我们所要做的是使用独立按键控制led的亮灭,所以首先我们要了解一个新的模块

即独立按键模块,这个模块有四个按键组成,在进行代码编写时一般由P3来对其状态进行判断,按下视为0,抬起视为1.后缀“_+数字”即表示控制的是(数字+1)按键,因为是从0开始的,但是不同型号也有一些区别,比如我的单片机按键1后缀的是_1,而按键2后缀的是_0.
下面就是编写代码,这里需要运用到选择结构,即按键按下时led亮,按键松开led灭,

#include <REGX52.H>
void main()
{
while(1)
{
if(P3_1==0)
{
P2_0=0;
}
else
{
P2_0=1;
}
}
}接着在stc中打开文件并进行编译,对单片机冷启动

显示操作成功时对单片机独立按键进行操作,现象是按下按键1是led点亮,松开熄灭
边栏推荐
- QT serialization 1: readyRead() function, the solution to incomplete data subcontracting
- 超详细的PCB高可靠辨别方法
- 暂时存着阿里云
- C语言,库函数中qsort的用法,及解释
- i++与 ++i 的区别
- Word使用中常用的快捷键
- [Common usage of markdown]
- VSCode hides the left activity bar
- [Jiangsu University of Science and Technology Automation Association stm32F103c8t6] Notes [Initial 32 MCU and TIM timing interrupt initialization parameter configuration]
- Insert map data efficiently
猜你喜欢

查看 word版本号
![Massive remote sensing data processing and application of GEE cloud computing technology [basic, advanced]](/img/38/239933ac987da762135db2d13902d0.png)
Massive remote sensing data processing and application of GEE cloud computing technology [basic, advanced]

查找Proj4js地图投影参数

Kunlun state screen production (serial 3) - based article (button serial port to send)

无法完成包的安装npm ERR! Refusing to install package with name “moment“ under a package also called “moment“

【江科大自化协stm32F103c8t6】笔记之【入门32单片机及利用TIM输出比较配置PWM】

FPGA parsing B code----serial 2

QT serialization 1: readyRead() function, the solution to incomplete data subcontracting

【markdown常用用法】

【已解决:el-input标签无法输入或不显示文字】
随机推荐
[Common usage of markdown]
c语言编程练习
[Punctuality Atom] Learning and use of IIC (unfinished...)
Written before the official account - QT, ARM, DSP, microcontroller, power electronics and transmission!
led闪烁
vscode set sublime theme
>>> /deep/ ::v-deep 深度作用选择器
QT weekly skills (3)~~~~~~~~~ serial port addition
主机和从机配置,建立ssh连接实现Rviz远程控制
【速成MSP430f149】电赛期间学习MSP430f149笔记
js高级学习笔记(详细)
Through the bit operations to convert the characters are case sensitive
Explore the efficiency of make_shared
关于报错vscode
The most complete difference between sizeof and strlen, as well as pointer and array operation analysis
openssl1.1.1ARM dual compilation
迷宫问题----经典回溯法解决
动态规划进阶 JS
VsCode打开终端的方法
独立按键控制led进阶(1)