Please help, i build this code but it keeps showing me this error, i already check the braces and all of them matches, i don’t know what’s wrong, please someone help me, here’s the code:
void setup() {
for (int i=2;i<=11;i++) {
pinMode(i,OUTPUT);
}
pinMode(12,INPUT);
pinMode(13,INPUT);
pinMode(A0,INPUT);
pinMode(A1,INPUT);
pinMode(A2,INPUT);
int boton=0;
//Funcion que prende y apaga un led y pone un delay
void flash(int led, int tiempo){
digitalWrite(led,1);
delay(tiempo);
digitalWrite(led,0);
delay(tiempo);
}
//Funcion que prende y apaga 5 leds con un delay entre medias
void flash5(int led1,int led2,int led3,int led4,int led5, int tiempo) {
digitalWrite(led1,1);
digitalWrite(led2,1);
digitalWrite(led3,1);
digitalWrite(led4,1);
digitalWrite(led5,1);
delay(tiempo);
digitalWrite(led1,0);
digitalWrite(led2,0);
digitalWrite(led3,0);
digitalWrite(led4,0);
digitalWrite(led5,0);
delay(tiempo);
}
//Funcion que prende 3 leds
void flash1(int led1,int led2,int led3){
digitalWrite(led1,1);
digitalWrite(led2,1);
digitalWrite(led3,1);
}
//Funcion que prende 4 leds
void flash2(int led1,int led2,int led3,int led4){
digitalWrite(led1,1);
digitalWrite(led2,1);
digitalWrite(led3,1);
digitalWrite(led4,1);
}
//Funcion que apaga 3 leds
void flash3(int led1,int led2,int led3,int tiempo){
digitalWrite(led1,0);
digitalWrite(led2,0);
digitalWrite(led3,0);
delay(tiempo);
}
//Funcion que apaga 4 leds
void flash4(int led1,int led2,int led3,int led4,int tiempo){
digitalWrite(led1,0);
digitalWrite(led2,0);
digitalWrite(led3,0);
digitalWrite(led4,);
delay(tiempo);
}
//Funcion de la animacion 1
void animacion1() {
flash5(2,4,6,8,10,30);
flash5(2,4,6,8,10,30);
flash5(3,5,7,9,11,30);
flash5(3,5,7,9,11,30);
}
//Funcion de la animacion 2
void animacion2() {
flash1(3,6,9);
flash4(2,5,8,11,30);
flash2(2,5,8,11);
flash3(4,7,10,30);
flash1(4,7,10);
flash3(3,6,9,30);
}
//Funcion de la animacion 3
void animacion3() {
flash1(3,5,7);
delay(30);
flash3(3,5,7,30);
flash1(6,8,10);
delay(30);
flash3(6,8,10,30);
flash2(9,11,2,4);
delay(30);
flash4(9,11,2,4,30);
}
//Funcion de la animacion de los leds aleatorios
void aleatorio() {
int aleatorio=random(2,11);
if(aleatorio==2) {
flash(2,30);
flash(2,30);
}
else if(aleatorio==3) {
flash(3,30);
flash(3,30);
}
else if(aleatorio==4) {
flash(4,30);
flash(4,30);
}
else if(aleatorio==5) {
flash(5,30);
flash(5,30);
}
else if(aleatorio==6) {
flash(6,30);
flash(6,30);
}
else if(aleatorio==7) {
flash(7,30);
flash(7,30);
}
else if(aleatorio==8) {
flash(8,30);
flash(8,30);
}
else if(aleatorio==9) {
flash(9,30);
flash(9,30);
}
else if(aleatorio==10) {
flash(10,30);
flash(10,30);
}
else if(aleatorio==11) {
flash(11,30);
flash(11,30);
}
}
//Funcion para parar las animaciones
void parar() {
for(int i=2;i<=11;i++) {
digitalWrite(i,0);
}
}
}
void loop() {
if (digitalRead(12)==1) {
boton=1;
delay(300);
}
else if (digitalRead(13)==1) {
boton=2;
delay(300);
}
else if (digitalRead(A0)==1) {
boton=3;
delay(300);
}
else if (digitalRead(A1)==1) {
boton=4;
delay(300);
}
else if (digitalRead(A2)==1) {
boton=5;
delay(300);
}
switch(boton) {
case 1: animacion1();
break;
case 2: animacion2();
break;
case 3: animacion3();
break;
case 4: aleatorio();
break;
case 5: parar();
break;
}
}