Advertisement
3rdWard_Arduino

Class3_Arrary_6LedsRandom

Feb 8th, 2012
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. int ledPins[] = {3, 5, 6, 9, 10, 11};// hard code locations for leds
  2. const int numVals = 6;
  3. int pwmVals[numVals];
  4.  
  5. void setup(){
  6.   for( int i = 0; i < numVals; i++){
  7.     pinMode(ledPins[i], OUTPUT);
  8.     pwmVals[i] = 0;
  9.   }
  10. }
  11. void loop(){
  12.   for( int i = 0; i < numVals; i++){
  13.     pwmVals[i] = int( random(255) );
  14.     analogWrite(ledPins[i], pwmVals[i]);
  15.   }
  16.   delay(100);
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement