好了,现在得开始更新了,已经落后一大截了,趁最近有时间得赶回来。
1、板子靓照..........................................................................6楼
2、简单的流水灯..................................................................7楼
3、数码管显示加定时器秒表...............................................9楼(2011/12/13更新)
4、lcd显示,定时器实现时钟............................................10楼(2011/12/15更新)
5、DS18B20的LED显示...................................................14楼(2011/12/18更新)
6、DS1302时钟,星期自动转换,闰年识别(视频).......15、16楼(2011/12/23更新)
7、定时器模拟PWM电机控制(温控风扇).......................17楼(2011/12/27更新)
8、步进电机资料....................................................................18楼
zhuludiqing MCU DIY进程帖(步进电机)

只看楼主 1楼
关键词: zhuludiqing 进程 步进 电机






7楼
流水灯小程序
#include<reg52.h>
#include<intrins.h>
void Delay(unsigned int);
void main()
{
int i=0;
unsigned char temp=0x01;
while(1)
{
for(i=0;i<7;i++)
{
temp=_crol_(temp,1);
P1=temp;
Delay(300);
}
}
}
延迟程序我给写到reg52.h里了。像这种短而常用的,我一般喜欢写到reg52.h里。像显示键盘扫描等大一点的程序,一般写自己建的头文件里,方便调用改错。
这个是写在reg52.h里的延迟程序
void Delay(unsigned int z)
{
unsigned int x,y;
for(x=z;x>0;x--)
for(y=110;y>0;y--);
}
#include<reg52.h>
#include<intrins.h>
void Delay(unsigned int);
void main()
{
int i=0;
unsigned char temp=0x01;
while(1)
{
for(i=0;i<7;i++)
{
temp=_crol_(temp,1);
P1=temp;
Delay(300);
}
}
}
延迟程序我给写到reg52.h里了。像这种短而常用的,我一般喜欢写到reg52.h里。像显示键盘扫描等大一点的程序,一般写自己建的头文件里,方便调用改错。
这个是写在reg52.h里的延迟程序
void Delay(unsigned int z)
{
unsigned int x,y;
for(x=z;x>0;x--)
for(y=110;y>0;y--);
}

8楼
刚才有事,写的有点仓促,现在补一个
#include<reg52.h>
#include<intrins.h>
void main()
{
int i=0;
unsigned char temp;
while(1)
{
temp=0xfe;
for(i=0;i<7;i++)
{
temp=_crol_(temp,1);//循环左移1位
P1=temp;
Delay(300); //适当延迟(晶振频率(24M、Delay(1)=0.5ms)
}
temp=0xfc;
for(i=0;i<7;i++)
{
temp=_crol_(temp,1);
P1=temp;
Delay(300);
}
temp=0x08;
for(i=0;i<7;i++)
{
temp=_crol_(temp,1);
P1=temp;
Delay(300);
}
}
}

9楼
#include<reg52.h>
#include"DISPLAY.h"
#include"INIT.h"
uchar flag;
char sec=0;
void main()
{
init();
while(1)
{
Display_show(sec);
TR0=1;
}
}
void time0() interrupt 1
{
TH0=(65536-20000)/256;//10us延迟,晶振24M
TL0=(65536-20000)%256;
flag++;
if(flag==100)//1s延迟
{
flag=0;
Display_show(sec);
flag++;
if(sec==60)
{
sec=0;
}
}
}
头文件在下面一
——回复可见内容——

#include"DISPLAY.h"
#include"INIT.h"
uchar flag;
char sec=0;
void main()
{
init();
while(1)
{
Display_show(sec);
TR0=1;
}
}
void time0() interrupt 1
{
TH0=(65536-20000)/256;//10us延迟,晶振24M
TL0=(65536-20000)%256;
flag++;
if(flag==100)//1s延迟
{
flag=0;
Display_show(sec);
flag++;
if(sec==60)
{
sec=0;
}
}
}
头文件在下面一
——回复可见内容——


回复
有奖活动 | |
---|---|
【有奖活动】分享技术经验,兑换京东卡 | |
话不多说,快进群! | |
请大声喊出:我要开发板! | |
【有奖活动】EEPW网站征稿正在进行时,欢迎踊跃投稿啦 | |
奖!发布技术笔记,技术评测贴换取您心仪的礼品 | |
打赏了!打赏了!打赏了! |
打赏帖 | |
---|---|
Buck电路工作在CCM模式下电感电流的计算公式是什么?被打赏5分 | |
buck电路工作原理被打赏5分 | |
基于MSPM0L1306的MODBUS-RTU协议通讯实验被打赏50分 | |
每周了解几个硬件知识+485硬件知识分享被打赏10分 | |
【换取手持示波器】树莓派PICOW网页烟花被打赏18分 | |
【换取手持示波器】树莓派PICO逻辑分析仪被打赏16分 | |
【分享评测,赢取加热台】教你五分钟本地部署蒸馏版本的DeepSeekR1-7B被打赏12分 | |
【换取手持示波器】蓝牙音箱更换电池被打赏8分 | |
【换取手持示波器】鼠标更换微动开关被打赏10分 | |
【我要开发板】4.传感器移植被打赏50分 |