/*
two master leds - 6 step leds
2-3 = master
4-6 = subA
6-9 = subB
*/
int timer = 125; //delay time
int sub_num = 3; //faster switching pins
int root_num = 2; //slower switching pins
int total_num = 8; //total pins
int pins_root[] = {2, 3};
int pins_sub[] = {4, 5, 6, 7,8,9};
void setup(){
int i;
for (i = 0; i < total_num; i++){
pinMode(pins_root[i], OUTPUT);
pinMode(pins_sub[i], OUTPUT);
}
}
void loop(){
int j;
int i;
int sub;
for(i=0; i< root_num; i++){
digitalWrite(pins_root[i], HIGH);
delay(timer *2 );
if(i == 0){ //determine which subpin path to take
sub = 0;
}
else if(i == 1){
sub = 3;
}
for(j = sub; j < sub+sub_num ; j++){ //go through sub pins. if all three are lit, turn them off.
delay(timer);
digitalWrite(pins_sub[j], HIGH);
delay(timer);
if(j == sub + 2){
subOff(sub);
}
}
digitalWrite(pins_root[i], LOW);
}
}
//switch off row
void subOff(int sub){
int r;
delay(timer);
for(r = 0; r < sub+sub_num; r++){
digitalWrite(pins_sub[r], LOW);
}
}
I remember those days that my brother is having hard time in their prototype. It's really complicated.Huh!
Posted by: casino en ligne | 12/19/2011 at 09:56 AM