当前位置:网站首页>51 single chip microcomputer learning_ 1.3 LED water lamp
51 single chip microcomputer learning_ 1.3 LED water lamp
2022-04-21 08:33:00 【Liujiashan No.1 miner】
explain
Delay100ms(unsigned char turn) Is the delay function , Time delay : turn * 0.1s
mypow(unsigned int a,unsigned int b): Calculation a Of b Power
control LED Light up one by one , You need to continuously cycle through the following code
T = 1111 1111
P2 = 1111 1110 //T - 1
P2 =1111 1101 //T - 2
P2 = 1111 1011 //T - 4
P2 = 1111 0111 //T - 8
P2 = 1110 1111 //T - 16
P2 = 1101 1111 //T - 32
P2 = 1011 1111 //T - 64
P2 = 0111 1111 //T - 128
It's actually T subtract 2 ^ i
Code
#include <REGX52.H>
#include <INTRINS.H>
void Delay100ms(unsigned char turn) //@11.0592MHz
{
while(turn--){
unsigned char i, j, k;
_nop_();
_nop_();
i = 5;
j = 52;
k = 195;
do
{
do
{
while (--k);
} while (--j);
} while (--i);
}
}
int mypow(unsigned int a,unsigned int b){
unsigned int i=0;
for(i;i<b;i++){
a=a*a;
}
return a;
}
void main(){
unsigned int T=0xff;
unsigned int i=0;
while(1){
for(i;i<8;i++){
P2=T-mypow(i,2);
Delay100ms(2); //500ms
}
}
}
版权声明
本文为[Liujiashan No.1 miner]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204210825344634.html
边栏推荐
- 关于组织申报2022年度山东省首台(套)技术装备及关键核心零部件项目的通知
- 【转载】深入浅出的讲解傅里叶变换
- 36氪首发|「甄知科技」收购数智化开发平台「猪齿鱼」,将和已有产品「燕千云」融合形成产品闭环
- 线性回归api
- Be sure to watch the nine steps of MES selection, which is worth collecting and watching repeatedly (Part 2)
- knn之交叉验证,网格搜索
- Ehcart map
- 数据集划分小探
- Comprehensive case: pinyougou project (pinyougou project process, SEO optimization, TDK three labels and codes) will be gradually optimized in the later stage
- Machine learning notes - SVD singular value decomposition (2)
猜你喜欢
随机推荐
knn预测最小案例总结
7.4 并行卷积神经网络 GoogleNet
Explanation of dbug debugging icon in idea
Webapi (VI) - BOM
Thinkphp快速入门(三)
Insert a new node before the linked list node
阿里巴巴温少再度出山重构fastjson推出fastjson2
卷积神经网络中二维卷积核与三维卷积核有什么区别?
Power grid enterprise standard B interface access record (II): resource reporting
go解析命令行参数 flag包
Common file types and content type of Apache Tika
JVM——》CMS
在链表结点后插入新结点
事务的隔离级别与MVCC
Count the number of linked lists and look up linked lists
How pbidea imports large medical insurance files
JVM——》G1垃圾收集器
[Nodejs]Nodejs基础补充(三)-this上下文对象
Experiment 1: basic operation of database
幽灵空白节点特性









