当前位置:网站首页>10.4.4 experiment of 8 LED "running lights" in 51 single chip microcomputer control system
10.4.4 experiment of 8 LED "running lights" in 51 single chip microcomputer control system
2022-04-22 19:32:00 【Lupin123123】
10.4.4 51 Single chip microcomputer control system 8 individual LED“ Running lights ” experiment
Simulation + Code

Method 1
Using the array
#include"reg52.h"
#define u8 unsigned char
#define u16 unsigned int
u16 a[] = {
0xff, 0xfe, 0xfd, 0xfb, 0xf7, 0xef, 0xdf, 0xbf, 0x7f};
void delayms(u16 ms)
{
u8 i;
while(ms--)
for (i=0; i<123; i++);
}
void main()
{
while(1)
{
u8 i;
for (i=1; i<=8; i++)
{
P1 = a[i];
delayms(500);
if (i==8) i=-1;
}
}
return;
}
Method 2
Using bit operations
#include"reg52.h"
#define u8 unsigned char
#define u16 unsigned int
void delayms(u16 ms)
{
u8 i;
while(ms--)
for (i=0; i<123; i++);
}
void main()
{
P1 = 0xfe;
while(1)
{
delayms(500);
P1 <<= 1;
P1 |= 0x01;
if (P1==0x7f)
{
delayms(500);
P1 = 0xfe;
}
}
}
版权声明
本文为[Lupin123123]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204221917527656.html
边栏推荐
- Where is the fastlist in the database connection pool hikaricp
- The SQL statement obtains each day, week, month and year according to the start and end date
- postman 测试 Array、List、Map 入参 API 正确姿势
- Understanding of string constant pool and intern method
- 短链接设计和思考
- Index in MySQL database (including SQL statement)
- 消息队列最佳实践
- .net 用supersocket搭建socket server
- 12-Delta Lake
- The third job analysis
猜你喜欢

Webrtc: mesh / MCU / SFU three communication architectures

If else optimization

调用mysql存储过程报错:mysql 1449 : The user specified as a definer ('root'@'%') does not exist

LeetCode 41. Missing first positive number

短链接设计和思考

Project training - Design and development of 2D multiplayer fighting game based on unity (v. use audiomixer to control the volume)

讲 透Object.prototype.toString.call()

ASP.NET之WEBAPI和webservice返回json数据

. net core minimal API upload file

WebRTC:Mesh/MCU/SFU三种通信架构
随机推荐
10-Streaming Query
. net background upload pictures without saving pictures to compress pictures
js复制粘贴,clipboard.js
13-Set Time Zone
Project training - Design and development of 2D multiplayer fighting game based on unity (v. use audiomixer to control the volume)
Revit (5) - second opening - creating walls
.NET学习笔记(三)----无处不在的特性
Influxdb根据time删除某条数据
Revit (4) - 二开 -创建批量创建柱子
The SQL statement obtains each day, week, month and year according to the start and end date
.net core minimal api 上传文件
linux 下mysql 5.6的一些操作
Type of Flink window
Detailed network structure diagram of dbnet character detection
asp.net反编译和防止反编译方法
JS copy and paste, clipboard js
Solution for C10K scenario of ICBC distributed service
Cannot proceed because system tables used by Event Scheduler were found damaged
ReDet 代码逐行解读
(3) MySQL constraints