This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

  • 0 voto(s) - 0 Media
  • 1
  • 2
  • 3
  • 4
  • 5
Problema Arduino
#1
Buenas! Recien me estoy metiendo en el mundo de arduino por un proyecto que estoy haciendo. Me fue todo bien hasta la hora de programar (no tengo idea). Un chico hizo algo parecido a lo mio y por suerte me pasó su codigo para que me sirviera de base. Crei que solo habia que cambiar en que pin estaba conectado los switchs y listo, pero parece que hay otro problema.
El proyecto es un footswitch o controlador MIDI y tengo 2 botones nada mas (mas adelante agregaria mas). El tema es que cuando le doy verificar me saltan error. Les paso el codigo a ver si pueden encontrar el error, Muchisimas gracias

int Control1 = 0;
int ControlAnt1 = 0;
int pot1 = 0;

int push1 = LOW, push2 = LOW, push3 = LOW; // push6 = LOW, push7 = LOW, push8 =LOW;
int edoant1 = LOW, edoant2 = LOW, edoant3 = LOW;  // edoant6 = LOW, edoant7 = LOW, edoant8 = LOW;
int edo1 = 0, edo2 = 0, edo3 = 0, edo4 = 0, edo5 = 0; // edo6 = 0, edo7 = 0 , edo8 = 0;

void setup() {
  Serial.begin(115200);
  pinMode(13, INPUT);
  pinMode(12, INPUT);
  pinMode(11, INPUT);
  }
  
void loop() {
  push1 = digitalRead(13);
  push2 = digitalRead(12);
  push3 = digitalRead(11);
  
  Control1 = map(pot1, 0, 1023, 0, 127);
}

  //---------------BOTON 1---------------------------------

  if (push1 == HIGH && edoant1 == LOW) {
    edo1 = 1 - edo1;
    Serial.write(176); // Mensaje sobre el Canal 1
    Serial.write(16); // Nota, CC, PC
    Serial.write(127); // Valor On
    edoant1 = push1;
 }

  if (push1 == LOW && edoant1 == HIGH) {
    Serial.write(176);
    Serial.write(16);
    Serial.write(0); // Valor Off
    edoant1 = push1;
  }


  //----------------BOTON 2---------------------------------

  if (push2 == HIGH && edoant2 == LOW) {
    edo2 = 1 - edo2;
    Serial.write(176);
    Serial.write(17);
    Serial.write(127);
    edoant2 = push2;
}
  if (push2 == LOW && edoant2 == HIGH) {
    Serial.write(176);
    Serial.write(17);
    Serial.write(0);
    edoant2 = push2;
  }
  Responder
#2
Hola, estas cerrando la rutina Loop despues de la línea 'Control1 = map(pot1, 0, 1023, 0, 127);', con lo cual el resto del código no está dentro de ninguna función y por eso te da error.
Quita el '}' de la línea siguiente a la que te digo y ponlo en el final del código
saludos
  Responder