51单片机流水灯汇编与c语言程序附电路图
/*******flowing water light*********/
#include<reg51.h> #include<intrins.h>
#define uchar unsigned char #define uint unsigned int //延时函数
void Delay_ms(uint x) {
uchar i; while(x--) {
for(i=0;i<120;i++); } } //主函数 void main() {
P0=0xff; //P0口初始化
P0=0x01; //共阴接法,点亮最低位LED while(1) {
Delay_ms(1000); //延时约1s
P0=_crol_(P0,1); //P0 的值向左循环移动,_crol_()函数在头文件intrins.h中 } }