Estoy haciendo este codigo para un proyecto personal, pero al compilarlo me da error. Podriais ayudarme?
Este es el codigo:
const byte inputPin = 4;
unsigned int voltes = 0;
unsigned int contador = 0;
void setup() {
pinMode(inputPin, INPUT);
Serial.begin(9600);
if (Serial.available() > 0) {
voltes = Serial.parseInt();
}
void loop() {
int val = digitalRead(inputPin);
if (val == HIGH) {
contador = contador + 1;
}
if (contador == voltes) {
Serial.println("Has guanyat!!!");
}
else {
Serial.println(contador);
}
}
Este es el error:
/tmp/441519402/sketch_aug8a/sketch_aug8a.ino:16:13: error: a function-definition is not allowed here before '{' token
/tmp/441519402/sketch_aug8a/sketch_aug8a.ino:28:1: error: expected '}' at end of input
exit status 1
Gracias por vuestra ayuda.