:-?
Hi all, im new here and new to the world of microcontrollers.
So what did i do; i bought a arduino board to play around with. Nothing difficult, nothing specific.
So i found this knight rider thingie on this forum somewhere in an old topic. I upped the code to the arduino, wired the leds n resistors up the way i should and......
....the LEDs do light up, and the knight rider effect is running...but its inverted. What i mean is that there should be a light running from left to right and vice versa....but in my case al lights are on and one goes off from left to right and vice versa...
This is the code i used...:
int ledpin[] ={3,5,6,9,10,11};
int n = 0; //speed counter.
int i =0; // repeater.
int value[] ={0,0,0,0,0,0};
void setup()
{
}
void loop()
{
if(n == 100){value[0]=255;}
if(n == 200){value[0]=255;}
if(n == 300){value[1]=255;}
if(n == 400){value[2]=255;}
if(n == 500){value[3]=255;}
if(n == 600){value[4]=255;}
if(n == 700){value[5]=255;}
if(n == 800){value[5]=255;}
if(n == 900){value[4]=255;}
if(n == 1000){value[3]=255;}
if(n == 1100){value[2]=255;}
if(n == 1200){value[1]=255;}
if(n >= 1200){n =0;}
for (i = 0; i <=5; i++)
{
if(value[i] >= 5){ value[i]-=1;}
else if (value[i] < 5) { value[i]=0;}
}
for (i = 0; i <=5; i++)
{
analogWrite(ledpin[i], value [i]);
}
n+=5;
delay(5);
}
Examples:
This is what i have
This is what it should be
So the code works and the hardware is connected properly...what can i do to fix it ?