#include<iom16v.h>
#include<macros.h>
#define uchar unsigned char
#define uint unsigned int
int i,j;
//右正转//
uchar Z[4]={0x03,0x06,0x0c,0x09}; //脉冲个数
//左反转//
uchar F[4]={0x09,0x0c,0x06,0x03};
void delay_1vs(uint time)
{
do
{ time--;}
while(time>1);
}
void delay_1ms(uint time)
{
while(time!=0)
{
delay_1vs(1000);
time--;
}
}
void L_zheng(int g)
{
DDRB|=BIT(0)|BIT(1)|BIT(2)|BIT(3);
for(i=0;i<g;i++)
{
for(j=0;j<4;j++)
{
PORTB=Z[j];
delay_1ms(50); //控制脉冲占空比
PORTB=0x00;
}
}
}
void R_zheng(int q)
{
DDRD|=BIT(0)|BIT(1)|BIT(2)|BIT(3);
for(i=0;i<q;i++)
{
for(j=0;j<4;j++)
{
PORTD=Z[j];
delay_1ms(50); //控制脉冲占空比
PORTD=0x00;
}
}
}
void main()
{
int a,c;
a=200;
c=200*200/1.696;
L_zheng(c);
R_zheng(c);
}
#include<macros.h>
#define uchar unsigned char
#define uint unsigned int
int i,j;
//右正转//
uchar Z[4]={0x03,0x06,0x0c,0x09}; //脉冲个数
//左反转//
uchar F[4]={0x09,0x0c,0x06,0x03};
void delay_1vs(uint time)
{
do
{ time--;}
while(time>1);
}
void delay_1ms(uint time)
{
while(time!=0)
{
delay_1vs(1000);
time--;
}
}
void L_zheng(int g)
{
DDRB|=BIT(0)|BIT(1)|BIT(2)|BIT(3);
for(i=0;i<g;i++)
{
for(j=0;j<4;j++)
{
PORTB=Z[j];
delay_1ms(50); //控制脉冲占空比
PORTB=0x00;
}
}
}
void R_zheng(int q)
{
DDRD|=BIT(0)|BIT(1)|BIT(2)|BIT(3);
for(i=0;i<q;i++)
{
for(j=0;j<4;j++)
{
PORTD=Z[j];
delay_1ms(50); //控制脉冲占空比
PORTD=0x00;
}
}
}
void main()
{
int a,c;
a=200;
c=200*200/1.696;
L_zheng(c);
R_zheng(c);
}

