微波EDA网,见证研发工程师的成长!
首页 > 硬件设计 > 嵌入式设计 > 单片机32口流水灯程序

单片机32口流水灯程序

时间:11-29 来源:互联网 点击:
#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;} 

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top