Hi guys,
Sorry but I need urgent help.
I want to run a stepper motor clockwise and anticlockwise by an ATMEGA16.
Can you guys please tell me what's the problem of the below instructions to do so?:
while (1)
{
if(PINB.0==0)
{
for(y=1;(PINB.0==0)&&(y<=x);y=y+1)
{
z=z+1;
if(z==1) PORTD=8;
if(z==2) PORTD=4;
if(z==3) PORTD=2;
if(z==4)
{
PORTD=1;
z=0;
}}}
delay_ms(10);
if (PINB.1==0)
{
for(y=1;(PINB.1==0)&&(y<=x);y=y+1)
{
z=z+1;
if(z==1) PORTD=1;
if(z==2) PORTD=2;
if(z==3) PORTD=4;
if(z==4)
{
PORTD=8;
z=1;
}} }
delay_ms(10);
}
}
Sorry but I need urgent help.
I want to run a stepper motor clockwise and anticlockwise by an ATMEGA16.
Can you guys please tell me what's the problem of the below instructions to do so?:
while (1)
{
if(PINB.0==0)
{
for(y=1;(PINB.0==0)&&(y<=x);y=y+1)
{
z=z+1;
if(z==1) PORTD=8;
if(z==2) PORTD=4;
if(z==3) PORTD=2;
if(z==4)
{
PORTD=1;
z=0;
}}}
delay_ms(10);
if (PINB.1==0)
{
for(y=1;(PINB.1==0)&&(y<=x);y=y+1)
{
z=z+1;
if(z==1) PORTD=1;
if(z==2) PORTD=2;
if(z==3) PORTD=4;
if(z==4)
{
PORTD=8;
z=1;
}} }
delay_ms(10);
}
}