simple:
Code:
void main()
{
int c;
int d;
int delaytime=50; //NEW VARIABLE
TRISD=0; //
TRISB=0X00;
TRISC=0X00;
PORTC=0X02;
PORTC=0X00;
c=0;
while(c<100)
{
_delay(delaytime); //<----new line here slows it down maybe too much
d++;
while(d=5000)
{
c++;
d=0;
PORTD=c;
PORTB=0X01;
_delay(5000);
PORTB=0X00;
}
}
}
To control speed you can either manual set delaytime variable or have 2 buttons for the user. When button 1 is pressed it adds 1 to the delaytime variable and when button 2 is pressed it minus 1 from delaytime variable...
Be sure to check the buttons inside the loop... not before the delay to get a better feel for the buttons.... Also dont forget to delay after a button press so it wont alter the variable to fast .