hi there, i'm new to this forum and programming.
I have a teensy 4.0 and the issue is:
(non working code below, baut please follow this principle
i have 16 pushbuttons attached to the teensy.
the buttons should count up a variable (looperStati) with each press.
The code works, but on pins 6, 9, 10 and 13 the Variable always starts with 1!, not with 0.
or: with i++ always one more than it should be.
i tried different codes
swapped button.
same result.
Even weirder: when reset, everything except 6,9,10,13 works
after powerOn: every pini is one too hight!
ideas?
I have a teensy 4.0 and the issue is:
(non working code below, baut please follow this principle
i have 16 pushbuttons attached to the teensy.
the buttons should count up a variable (looperStati) with each press.
The code works, but on pins 6, 9, 10 and 13 the Variable always starts with 1!, not with 0.
or: with i++ always one more than it should be.
i tried different codes
swapped button.
same result.
Even weirder: when reset, everything except 6,9,10,13 works
after powerOn: every pini is one too hight!
ideas?
HTML:
String schalter [] = {"LO1", "LO2", "LO3", "LO4", "PB1", "PB2", "PB3", "PB4", "SO1", "SO2", "SO3", "SO4", "FX1", "FX2", "CLR", "S16"};
bool schalterA [16];
unsigned long timers [16];
unsigned long longClick = 700;
byte looperStati [16];
void looperDown (int i){
timers[i] = millis();
}
void looperUp (int i){
if ((millis() - timers[i]) < longClick) {
if (looperStati[i] == 0) {
Serial.print (schalter[i]);
Serial.println (" Recording");
looperStati[i]++;
}
else if (looperStati[i] == 1) {
Serial.print (schalter[i]);
Serial.println (" Playing");
looperStati[i]++;
}
else if (looperStati[i] == 2) {
Serial.print (schalter[i]);
Serial.println (" Stopped");
looperStati[i]++;
}
else if (looperStati[i] == 3) {
Serial.print (schalter[i]);
Serial.println (" Playing");
looperStati[i]++;
}
else if (looperStati[i] == 4) {
Serial.print (schalter[i]);
Serial.println (" Stopped");
looperStati[i] = 3;
}
}
if (((millis() - timers[i]) >= longClick) && looperStati[i] >= 3) {
Serial.print (schalter[i]);
Serial.println (" Recording");
looperStati[i] = 1;
}
}
void setup() {
for(int i=0; i<16; i++){
pinMode(i+5, INPUT_PULLUP);
schalterA[i] = HIGH;
looperStati[i] = 0;
}
Serial.begin(9600);
}
void loop() {
for (int i = 0; i < 16; i++)
{
bool inputVal = digitalRead(i + 5);
if (schalterA[i] != inputVal)
{
schalterA[i] = inputVal;
//Serial.println(schalter[i]);
if (inputVal)
looperUp (i);
else
looperDown (i);
}
}
}