Perdón por perderme XD, bueno aqui lo tengo acabado , solucioné parte del problema salvo que tengo que presionar el botón en un tiempo mayor a 0.5s , hay manera de regular esto?
int A[]={30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47};
int B[]={2,3,4,5,6,7,8,9,10,11,12,22,23,24,25,26,27,28};
int a;
int actual =0;
int ant = 0;
int a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15,a16,a17,a18,b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13,b14,b15,b16,b17,b18;
int count=0;
int led;
int bott;
void setup(){
for(int i=0;i<=17;i++){
pinMode(A[i],OUTPUT);
}
for(int i=0;i<=17;i++){
pinMode(B[i],INPUT);
}
randomSeed(analogRead(A0));
Serial.begin(9600);
}
void bottones(int x, int y,int actual, int ant){
a=digitalRead(B[y]);
if((a==HIGH)&&(ant==LOW)){
actual=1-actual;
delay(10);
}
ant=a;
if(actual==1){
digitalWrite(A[x],HIGH);
count=1+count;
delay(500);
}
}
int i=0;
void complejo(){
led=random(0,18);
bott=random(0,18);
a1=led;
b1=bott;
while( i==0){
led=random(0,18);
bott=random(0,18);
if((a1 != led)&&(b1 != bott)){
a2=led;
b2=bott;
i=1;
}
}
i=0;
while( i==0){
led=random(0,18);
bott=random(0,18);
if((a1 != led)&&(b1 != bott)&&(a2 != led)&&(b2 != bott)){
a3=led;
b3=bott;
i=1;
}
}
i=0;
while( i==0){
led=random(0,18);
bott=random(0,18);
if((a1 != led)&&(b1 != bott)&&(a2 != led)&&(b2 != bott)&&(a3 != led)&&(b3 != bott)){
a4=led;
b4=bott;
i=1;
}
}
i=0;
while( i==0){
led=random(0,18);
bott=random(0,18);
if((a1 != led)&&(b1 != bott)&&(a2 != led)&&(b2 != bott)&&(a3 != led)&&(b3 != bott)&&(a4 != led)&&(b4 != bott)){
a5=led;
b5=bott;
i=1;
}
}
i=0;
while( i==0){
led=random(0,18);
bott=random(0,18);
if((a1 != led)&&(b1 != bott)&&(a2 != led)&&(b2 != bott)&&(a3 != led)&&(b3 != bott)&&(a4 != led)&&(b4 != bott)&&(a5 != led)&&(b5 != bott)){
a6=led;
b6=bott;
i=1;
}
}
i=0;
while( i==0){
led=random(0,18);
bott=random(0,18);
if((a1 != led)&&(b1 != bott)&&(a2 != led)&&(b2 != bott)&&(a3 != led)&&(b3 != bott)&&(a4 != led)&&(b4 != bott)&&(a5 != led)&&(b5 != bott)&&(a6 != led)&&(b6 != bott)){
a7=led;
b7=bott;
i=1;
}
}
i=0;
while( i==0){
led=random(0,18);
bott=random(0,18);
if((a1 != led)&&(b1 != bott)&&(a2 != led)&&(b2 != bott)&&(a3 != led)&&(b3 != bott)&&(a4 != led)&&(b4 != bott)&&(a5 != led)&&(b5 != bott)&&(a6 != led)&&(b6 != bott)&&(a7 != led)&&(b7 != bott)){
a8=led;
b8=bott;
i=1;
}
}
i=0;
while( i==0){
led=random(0,18);
bott=random(0,18);
if((a1 != led)&&(b1 != bott)&&(a2 != led)&&(b2 != bott)&&(a3 != led)&&(b3 != bott)&&(a4 != led)&&(b4 != bott)&&(a5 != led)&&(b5 != bott)&&(a6 != led)&&(b6 != bott)&&(a7 != led)&&(b7 != bott)&&(a8 != led)&&(b8 != bott)){
a9=led;
b9=bott;
i=1;
}
}
i=0;
while( i==0){
led=random(0,18);
bott=random(0,18);
if((a1 != led)&&(b1 != bott)&&(a2 != led)&&(b2 != bott)&&(a3 != led)&&(b3 != bott)&&(a4 != led)&&(b4 != bott)&&(a5 != led)&&(b5 != bott)&&(a6 != led)&&(b6 != bott)&&(a7 != led)&&(b7 != bott)&&(a8 != led)&&(b8 != bott)&&(a9 != led)&&(b9 != bott)){
a10=led;
b10=bott;
i=1;
}
}
i=0;
while( i==0){
led=random(0,18);
bott=random(0,18);
if((a1 != led)&&(b1 != bott)&&(a2 != led)&&(b2 != bott)&&(a3 != led)&&(b3 != bott)&&(a4 != led)&&(b4 != bott)&&(a5 != led)&&(b5 != bott)&&(a6 != led)&&(b6 != bott)&&(a7 != led)&&(b7 != bott)&&(a8 != led)&&(b8 != bott)&&(a9 != led)&&(b9 != bott)&&(a10 != led)&&(b10 != bott)){
a11=led;
b11=bott;
i=1;
}
}
i=0;
while( i==0){
led=random(0,18);
bott=random(0,18);
if((a1 != led)&&(b1 != bott)&&(a2 != led)&&(b2 != bott)&&(a3 != led)&&(b3 != bott)&&(a4 != led)&&(b4 != bott)&&(a5 != led)&&(b5 != bott)&&(a6 != led)&&(b6 != bott)&&(a7 != led)&&(b7 != bott)&&(a8 != led)&&(b8 != bott)&&(a9 != led)&&(b9 != bott)&&(a10 != led)&&(b10 != bott)&&(a11 != led)&&(b11 != bott)){
a12=led;
b12=bott;
i=1;
}
}
i=0;
while( i==0){
led=random(0,18);
bott=random(0,18);
if((a1 != led)&&(b1 != bott)&&(a2 != led)&&(b2 != bott)&&(a3 != led)&&(b3 != bott)&&(a4 != led)&&(b4 != bott)&&(a5 != led)&&(b5 != bott)&&(a6 != led)&&(b6 != bott)&&(a7 != led)&&(b7 != bott)&&(a8 != led)&&(b8 != bott)&&(a9 != led)&&(b9 != bott)&&(a10 != led)&&(b10 != bott)&&(a11 != led)&&(b11 != bott)&&(a12 != led)&&(b12 != bott)){
a13=led;
b13=bott;
i=1;
}
}
i=0;
while( i==0){
led=random(0,18);
bott=random(0,18);
if((a1 != led)&&(b1 != bott)&&(a2 != led)&&(b2 != bott)&&(a3 != led)&&(b3 != bott)&&(a4 != led)&&(b4 != bott)&&(a5 != led)&&(b5 != bott)&&(a6 != led)&&(b6 != bott)&&(a7 != led)&&(b7 != bott)&&(a8 != led)&&(b8 != bott)&&(a9 != led)&&(b9 != bott)&&(a10 != led)&&(b10 != bott)&&(a11 != led)&&(b11 != bott)&&(a12 != led)&&(b12 != bott)&&(a13 != led)&&(b13 != bott)){
a14=led;
b14=bott;
i=1;
}
}
i=0;
while( i==0){
led=random(0,18);
bott=random(0,18);
if((a1 != led)&&(b1 != bott)&&(a2 != led)&&(b2 != bott)&&(a3 != led)&&(b3 != bott)&&(a4 != led)&&(b4 != bott)&&(a5 != led)&&(b5 != bott)&&(a6 != led)&&(b6 != bott)&&(a7 != led)&&(b7 != bott)&&(a8 != led)&&(b8 != bott)&&(a9 != led)&&(b9 != bott)&&(a10 != led)&&(b10 != bott)&&(a11 != led)&&(b11 != bott)&&(a12 != led)&&(b12 != bott)&&(a13 != led)&&(b13 != bott)&&(a14 != led)&&(b14 != bott)){
a15=led;
b15=bott;
i=1;
}
}
i=0;
while( i==0){
led=random(0,18);
bott=random(0,18);
if((a1 != led)&&(b1 != bott)&&(a2 != led)&&(b2 != bott)&&(a3 != led)&&(b3 != bott)&&(a4 != led)&&(b4 != bott)&&(a5 != led)&&(b5 != bott)&&(a6 != led)&&(b6 != bott)&&(a7 != led)&&(b7 != bott)&&(a8 != led)&&(b8 != bott)&&(a9 != led)&&(b9 != bott)&&(a10 != led)&&(b10 != bott)&&(a11 != led)&&(b11 != bott)&&(a12 != led)&&(b12 != bott)&&(a13 != led)&&(b13 != bott)&&(a14 != led)&&(b14 != bott)&&(a15 != led)&&(b15 != bott)){
a16=led;
b16=bott;
i=1;
}
}
i=0;
while( i==0){
led=random(0,18);
bott=random(0,18);
if((a1 != led)&&(b1 != bott)&&(a2 != led)&&(b2 != bott)&&(a3 != led)&&(b3 != bott)&&(a4 != led)&&(b4 != bott)&&(a5 != led)&&(b5 != bott)&&(a6 != led)&&(b6 != bott)&&(a7 != led)&&(b7 != bott)&&(a8 != led)&&(b8 != bott)&&(a9 != led)&&(b9 != bott)&&(a10 != led)&&(b10 != bott)&&(a11 != led)&&(b11 != bott)&&(a12 != led)&&(b12 != bott)&&(a13 != led)&&(b13 != bott)&&(a14 != led)&&(b14 != bott)&&(a15 != led)&&(b15 != bott)&&(a16 != led)&&(b16 != bott)){
a17=led;
b17=bott;
i=1;
}
}
i=0;
while( i==0){
led=random(0,18);
bott=random(0,18);
if((a1 != led)&&(b1 != bott)&&(a2 != led)&&(b2 != bott)&&(a3 != led)&&(b3 != bott)&&(a4 != led)&&(b4 != bott)&&(a5 != led)&&(b5 != bott)&&(a6 != led)&&(b6 != bott)&&(a7 != led)&&(b7 != bott)&&(a8 != led)&&(b8 != bott)&&(a9 != led)&&(b9 != bott)&&(a10 != led)&&(b10 != bott)&&(a11 != led)&&(b11 != bott)&&(a12 != led)&&(b12 != bott)&&(a13 != led)&&(b13 != bott)&&(a14 != led)&&(b14 != bott)&&(a15 != led)&&(b15 != bott)&&(a16 != led)&&(b16 != bott)&&(a17 != led)&&(b17 != bott)){
a18=led;
b18=bott;
i=1;
}
}
}
void loop() {
for(int i=0;i<=17;i++){
digitalWrite(A[i],LOW);
}
delay(2000);
complejo();
while(count<=18){
bottones(a1,b1,0,0);
bottones(a2,b2,0,0);
bottones(a3,b3,0,0);
bottones(a4,b4,0,0);
bottones(a5,b5,0,0);
bottones(a6,b6,0,0);
bottones(a7,b7,0,0);
bottones(a8,b8,0,0);
bottones(a9,b9,0,0);
bottones(a10,b10,0,0);
bottones(a11,b11,0,0);
bottones(a12,b12,0,0);
bottones(a13,b12,0,0);
bottones(a14,b14,0,0);
bottones(a15,b15,0,0);
bottones(a16,b16,0,0);
bottones(a17,b17,0,0);
bottones(a18,b18,0,0);
}
delay(2000);
}