- #include
- #define uint unsigned int
- #define ucher unsigned char
- unsigned char code ZZ[8]={0x09,0x01,0x03,0x02,0x06,0x04,0x0c,0x08};//28BYJ-48正时钟旋转相序表
- unsigned char code FZ[8]={0x08,0x0c,0x04,0x06,0x02,0x03,0x01,0x09};//28BYJ-48逆时钟旋转相序表
- void delay(unsigned int n)//毫秒级延时
- {
- unsigned int i,j;
- for(j=n;j>0;j--)
- for(i=112;i>0;i--);
- }
- void BGdelay(unsigned int n)//步进延时
- {
- unsigned int i;
- for(n;n>0;n--)
- for(i=96;i>0;i--);
- }
- void main(void)//入口函数
- {
- unsigned int i;
- delay(500);
- while(1)
- {
- for(i=0;i<8;i++) //旋转90度
- {
- P1=FZ[ i];
- BGdelay(1);
- }
- }
- }
复制代码
|