Friday, July 15, 2011

display a moving tail in arduino

this is a arduino program that uses led to make a moving tail effect
the source is below

/*
created by kuldeep dhaka
email:kuldeepdhaka9@gmail.com

how it work:
there are 11 boxes
array address    0  1  2  3  4  5  6  7  8  9  10
                 [] [] [] [] [] [] [] [] [] [] []
variable number  1  2  3  4  5  6  7  8  9  10 11
the last variable is to store the 10th variable value temporarily
shifting of values is done and the last one is shifted to first
the a loop is runned from 3 to 9
*/
//actual program start here:-
unsigned char i;
unsigned char led[]={3,5,6,9,10,11,7};
unsigned char tail[]={15,80,190,255,0,0,0,0,0,0,0};
void setup()
{
//do nothing
}
void loop()
{
//shifting values:-
for(i=9 ; i>=0; i--)
  {
  tail[i+1]=tail[i];
  }
tail[0]=tail[10];
//sending values to led:-
for(i=0;i<6;i++)
  {
  analogWrite(led[i],tail[i+3]);
  }
delay(500);
}

please leave comments [+report bug also if any]

Labels: , , , ,

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

Links to this post:

Create a Link

<< Home