Hi, I'm building a 16 switch midi foot controller.
Using a Teensy.
my code so far looks like this:
int LO1 = HIGH; int LO1_1 = HIGH;
int LO2 = HIGH; int LO2_1 = HIGH;
int LO3 = HIGH; int LO3_1 = HIGH;
int LO4 = HIGH; int LO4_1 = HIGH;
int PB1 = HIGH; int PB1_1 = HIGH;
int PB2 = HIGH; int PB2_1 = HIGH;
int PB3 = HIGH; int PB3_1 = HIGH;
int PB4 = HIGH; int PB4_1 = HIGH;
int SO1 = HIGH; int SO1_1 = HIGH;
int SO2 = HIGH; int SO2_1 = HIGH;
int SO3 = HIGH; int SO3_1 = HIGH;
int SO4 = HIGH; int SO4_1 = HIGH;
int FX1 = HIGH; int FX1_1 = HIGH;
int FX2 = HIGH; int FX2_1 = HIGH;
int CLR = HIGH; int CLR_1 = HIGH;
int S16 = HIGH; int S16_1 = HIGH;
String schalter [] = {"LO1", "LO2", "LO3", "LO4", "PB1", "PB2", "PB3", "PB4", "SO1", "SO2", "SO3", "SO4", "FX1", "FX2", "CLR", "S16"};
int schalterA [] = {LO1, LO2, LO3, LO4, PB1, PB2, PB3, PB4, SO1, SO2, SO3, SO4, FX1, FX2, CLR, S16};
int schalterB [] = {LO1_1, LO2_1, LO3_1, LO4_1, PB1_1, PB2_1, PB3_1, PB4_1, SO1_1, SO2_1, SO3_1, SO4_1, FX1_1, FX2_1, CLR_1, S16_1};
bool ply = false;
void setup() {
for(int i=5; i<21; i++){pinMode(i, INPUT_PULLUP);}
Serial.begin(9600);
}
void loop() {
for(int i=0; i<16; i++){
schalterA [i] = digitalRead(i+5);
if (schalterA[i] == LOW && schalterB[i] == HIGH) {
Serial.print(schalter[i]); Serial.println(" down");
schalterB[i] = schalterA[i];
}
if (schalterA[i] == HIGH && schalterB[i] == LOW) {
Serial.print(schalter[i]); Serial.println(" up");
schalterB[i] = schalterA[i];
}
}
}
So I basically tried to declare a bunch of Variable to store my pushbutton states (connected to Pins 5 to 20).
that code works so far.
My Question is: why do I have to use
if (schalterA[i] == LOW && schalterB[i] == HIGH)
to address my variables? because
if (LO1 == LOW && LO1_1 == HIGH)
gives me no result?
thanks a lot in advance.
Thomas