您的位置 首页 方案

单片机32口流水灯程序

includereg51h>includeintrinsh>includeabsacch>defineucharunsignedchardefineuintunsignedintde

#include

#include#include#define uchar unsigned char#define uint unsigned int#define TimeDelay 60000void delay(uint n);void Flash0a(void);void Flash0b(void);void Flash1a(void);void Flash1b(void);void Flash2a(void);void Flash2b(void);void Flash3a(void);void Flash3b(void);/*************************************************************Function: 主函数*parameter:*Return:*Modify:*************************************************************/void main(void){while(1){Flash1b();Flash1a();delay(TimeDelay);delay(TimeDelay);Flash0b();Flash0a();Flash2b();Flash2a();Flash1b();Flash1a();Flash3b();Flash3a();}}/*************************************************************Function: 延时*parameter:*Return:*Modify:*************************************************************/void delay(uint n){while(n!=0){n--;}}void Flash0a(void){uchar i;uchar Temp;Temp = 0x80;for(i=0;i<8;i++){P0 = ~Temp;delay(TimeDelay);Temp = Temp >> 1;}P0 = 0xff;}void Flash0b(void){uchar i;uchar Temp;Temp = 0x80;for(i=0;i<8;i++){P0 = Temp; delay(TimeDelay);Temp = Temp >> 1;}P0 = 0;}void Flash1a(void){uchar i;uchar Temp;P1 = 1;Temp = 0x80;for(i=0;i<8;i++){P1 = ~Temp;delay(TimeDelay);Temp = Temp >> 1;}P1 = 0xff;}void Flash1b(void){uchar i;uchar Temp;P1 = 1;Temp = 0x80;for(i=0;i<8;i++){P1 = Temp; delay(TimeDelay);Temp = Temp >> 1;}P1 = 0;}void Flash2a(void){uchar i;uchar Temp;P2 = 1;Temp = 0x80;for(i=0;i<8;i++){P2 = ~Temp;delay(TimeDelay);Temp = Temp >> 1;}P2 = 0xff;}void Flash2b(void){uchar i;uchar Temp;P2 = 1;Temp = 0x80;for(i=0;i<8;i++){P2 = Temp; delay(TimeDelay);Temp = Temp >> 1;}P2 = 0;}void Flash3a(void){uchar i;uchar Temp;P3 = 1;Temp = 0x80;for(i=0;i<8;i++){P3 = ~Temp;delay(TimeDelay);Temp = Temp >> 1;}P3 = 0xff;}void Flash3b(void){uchar i;uchar Temp;P3 = 1;Temp = 0x80;for(i=0;i<8;i++){P3 = Temp; delay(TimeDelay);Temp = Temp >> 1;}P3 = 0;} 

声明:本文内容来自网络转载或用户投稿,文章版权归原作者和原出处所有。文中观点,不代表本站立场。若有侵权请联系本站删除(kf@86ic.com)https://www.86ic.net/fangan/255317.html

为您推荐

联系我们

联系我们

在线咨询: QQ交谈

邮箱: kf@86ic.com

关注微信
微信扫一扫关注我们

微信扫一扫关注我们

返回顶部