MIDI Controller Poti+Buttons

Hey Guys,

i'm trying to build a MIDI Controller with some buttons and a few Potis. I'm using an arduino uno (seeduino). The Code for the buttons is working now.

int taste1 = LOW;
int taste1Alt = LOW;
int taste2 = LOW;
int taste2Alt = LOW;
int taste3 = LOW;
int taste3Alt = LOW;
int taste4 = LOW;
int taste4Alt = LOW;

void setup() {
Serial.begin(9600);
pinMode(5, INPUT);
pinMode(2, INPUT);
pinMode(3, INPUT);
pinMode(4, INPUT);
}

void loop(){
taste1 = digitalRead(1);

if (taste1 == HIGH && taste1Alt == LOW) {
sendeMIDI(144,36,127);
taste1Alt = taste1;
}

if (taste1 == LOW && taste1Alt == HIGH) {
sendeMIDI(144,36,0);
taste1Alt = taste1;
}

taste2 = digitalRead(2);

if (taste2 == HIGH && taste2Alt == LOW) {
sendeMIDI(144,36,127);
taste2Alt = taste2;
}

if (taste2 == LOW && taste2Alt == HIGH) {
sendeMIDI(144,36,0);
taste2Alt = taste2;
}

taste3 = digitalRead(3);

if (taste3 == HIGH && taste3Alt == LOW) {
sendeMIDI(144,38,127);
taste3Alt = taste3;
}

if (taste3 == LOW && taste3Alt == HIGH) {
sendeMIDI(144,38,0);
taste3Alt = taste3;
}

taste4 = digitalRead(5);

if (taste4 == HIGH && taste4Alt == LOW) {
sendeMIDI(144,40,127);
taste4Alt = taste4;
}

if (taste4 == LOW && taste4Alt == HIGH) {
sendeMIDI(144,40,0);
taste4Alt = taste4;
}

}

void sendeMIDI(int statusByte,int Note,int Velocity) {
Serial.write(statusByte);
Serial.write(Note);
Serial.write(Velocity);
}17

But the code for the potis is not really working...?

int controlChange = 176; // MIDI Kanal 1
byte controllerNummer = {20,21,22,23,24,25};
byte arduinoAnalogSlot = {A0, A1, A2, A3, A4, A5};
byte controllerValue = {0, 0, 0, 0, 0, 0};
byte tempControllerValue = {0, 0, 0, 0, 0, 0};
int value = {0, 0, 0, 0, 0, 0};

void setup() {
Serial.begin(9600);
}

void loop() {

for(byte i = 0; i<=5; i++){
value[i] = 0.2 * value[i] + 0.8 * analogRead(arduinoAnalogSlot[i]);
controllerValue[i] = map(value[i],0,1023,0,127);
if(controllerValue[i] != tempControllerValue[i]){
Serial.write(controlChange);
Serial.write(controllerNummer[i]);
Serial.write(controllerValue[i]);

  tempControllerValue[i] = controllerValue[i];

}
}
}

...is not any kind of explanation of the issues you are observing.

Please remember to use code tags when posting code

(Your button sketch is still too large)

You should not use magic numbers:
You changed your pinMode statement from 1 to 5:
pinMode(5, INPUT);
But you forgot to change the read statement as well:
taste1 = digitalRead(1);
That's a typical fault when using magical numbers.

Give your pins a name, and use only the name in the sketch:

const byte tast1Pin = 5;

in setup:
pinMode( taste1Pin, INPUT );

in loop:
taste1 = digitalRead(taste1Pin);

Than you need only to change one line when changing the pin arrangement.

If you use the same array approach as for the analog inputs also for the buttons, your sketch will be much shorter and clearer.

And what is the problem regarding the controllerchange?
What do you want to achive with this statement:
value[i] = 0.2 * value[i] + 0.8 * analogRead(arduinoAnalogSlot[i]);

And please use code-Tags ( Button </> in the edit line above ) when posting code!!!
Or right click in the code window of the IDE and select 'Für Forum kopieren'.

Hello,
take a piece of paper and some coloured pencils and draw a data- and control flow diagram. Keep in mind that the ussage of enums, structs and arrays C++ instructions will save coding work.