Is it possible to change this variable?

Hello everyone. I'm wondering if is it possible to do this:

I'm using the control surface library, and I would like to use a counter and put a variable inside the class "Button", so I could press a button and change the value of this variable.

If I use the serial monitor I see that the variable "CC1" actually changes, but when I check this in a midi software, nothing happens, is always sending the first value 0

Thanks!

#include <Control_Surface.h>

HairlessMIDI_Interface midi;

const int buttonPin = 0;     

int buttonState = 0;         
int prestate = 0;
int CC1 = 0;


int counter(){
  buttonState = digitalRead(buttonPin);

  if (buttonState == HIGH && prestate == 0) {
    CC1++;
    prestate = 1;
  } else if(buttonState == LOW) {
    prestate = 0;
  }
}


CCButtonLatched ComandosCC[] = {
  {2, {CC1, CHANNEL_1}},
};


void setup() {
  pinMode(buttonPin, INPUT);
  Control_Surface.begin();
}

void loop() {
  counter();
  Control_Surface.loop();
}
const int buttonPin = 0;

You don't say which Arduino board you are using, but is that the Serial Rx pin that you have the button attached to ?

Does the MIDI interface use a serial interface and if so, which one ?

a variable inside the class "Button"

As far as I can see you do not have a class named "Button" but I am not familiar with the libraries that you are using

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.