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];}
}
}