int ledselect;
int led1 = 1;
int led2 = 2;
int led3 = 3;
int led4 = 4;
int led5 = 5;
int led6 = 6;
int ir1 = 7;
int ir2 = 8;
int ir3 = 9;
int ir4 = 10;
int ir5 = 11;
int ir6 = 12;
int s1=A0;
int s2=A1;
int s3=A2;
int s4=A3;
int s5=A4;
int s6=A5;
void setup() {
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
pinMode(led4, OUTPUT);
pinMode(led5, OUTPUT);
pinMode(led6, OUTPUT);
pinMode(ir1, OUTPUT);
pinMode(ir2, OUTPUT);
pinMode(ir3, OUTPUT);
pinMode(ir4, OUTPUT);
pinMode(ir5, OUTPUT);
pinMode(ir6, OUTPUT);
pinMode(s1, INPUT);
pinMode(s2, INPUT);
pinMode(s3, INPUT);
pinMode(s4, INPUT);
pinMode(s5, INPUT);
pinMode(s6, INPUT);
}
void loop() {
int ledselect = random(6);
switch (ledselect) {
case 0:
digitalWrite(led1, HIGH);
digitalWrite(ir1, HIGH);
delay(20);
while(analogRead(s1) >= 950){delay(20);}
digitalWrite(led1,LOW);
break;
case 1:
digitalWrite(led2, HIGH);
digitalWrite(ir2, HIGH);
delay(20);
while(analogRead(s2) >= 950){delay(20);}
digitalWrite(led2,LOW);
break;
case 2:
digitalWrite(led3, HIGH);
digitalWrite(ir3, HIGH);
delay(20);
while(analogRead(s3) >= 950){delay(20);}
digitalWrite(led3,LOW);
break;
case 3:
digitalWrite(led4, HIGH);
digitalWrite(ir4, HIGH);
delay(20);
while(analogRead(s4) >= 950){delay(20);}
digitalWrite(led4,LOW);
case 4:
digitalWrite(led5, HIGH);
digitalWrite(ir5, HIGH);
delay(20);
while(analogRead(s5) >= 950){delay(20);}
digitalWrite(led5,LOW);
case 5:
digitalWrite(led6, HIGH);
digitalWrite(ir6, HIGH);
delay(20);
while(analogRead(s6) >= 950){delay(20);}
digitalWrite(led6,LOW);
break;
default:
delay(2000);
break;
}
}
Comments