[Solved] LED bar...but inverted !?
:-?
hi all, im new here , new world of microcontrollers.
so did do; bought arduino board play around with. nothing difficult, nothing specific.
so found knight rider thingie on forum somewhere in old topic. upped code arduino, wired leds n resistors way should and......
....the leds light up, , knight rider effect running...but inverted. mean there should light running left right , vice versa....but in case al lights on , 1 goes off left right , vice versa...
this code used...:
examples:
this have
[media]http://www.youtube.com/watch?v=o4sqlxfkfdg
[/media]
this should be
[media]http://www.youtube.com/watch?v=ues0qpk5ye4[/media]
so code works , hardware connected properly...what can fix ?
hi all, im new here , new world of microcontrollers.
so did do; bought arduino board play around with. nothing difficult, nothing specific.
so found knight rider thingie on forum somewhere in old topic. upped code arduino, wired leds n resistors way should and......
....the leds light up, , knight rider effect running...but inverted. mean there should light running left right , vice versa....but in case al lights on , 1 goes off left right , vice versa...
this code used...:
code: [select]
int ledpin[] ={3,5,6,9,10,11};
int n = 0; //speed counter.
int =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; <=5; i++)
{
if(value[i] >= 5){ value[i]-=1;}
else if (value[i] < 5) { value[i]=0;}
}
(i = 0; <=5; i++)
{
analogwrite(ledpin[i], value [i]);
}
n+=5;
delay(5);
}
examples:
this have
[media]http://www.youtube.com/watch?v=o4sqlxfkfdg
[/media]
this should be
[media]http://www.youtube.com/watch?v=ues0qpk5ye4[/media]
so code works , hardware connected properly...what can fix ?
this pretty crufty because don't "get" code that's there if lights opposite of want, change analogwrite 255-value . may not clean maybe move along.
Arduino Forum > Forum 2005-2010 (read only) > Software > Syntax & Programs > [Solved] LED bar...but inverted !?
arduino
Comments
Post a Comment