Hello everyone!
Beginner so be gentle.
I just can't get this to count up or down or right to left, what have I missed?
There is of course a lot of more code and such over this but I only need to get this below to work.
As now it only prints out 54 on a 20x4 lcd at second row 5 column (don't ask me why) and if I push the right left button* (button in this case is a piece of thread) nothing happens but if I push up or down it goes slightly haywire with "54" all over the display, its like the debounce doesn't work which I can't get.
The button and debounce thing is from the Arduino examples with of course the necessary changes. And yes I know the button things can be made much in some way smaller but I just don't have the effort for it, I just want it to work first.
There are ints, unsigned longs and so on for everything that is stated below.
The "done" and "done2" was recently added and obviously failed effort to prevent the loop to execute the entire code in the "case" over and over but only once every time any button was pushed depending on which.
Oh well here is the failure:
void check_buttons() {
 byte up_reading = digitalRead(53);
 byte down_reading = digitalRead(52);
 byte right_reading = digitalRead(49);
 byte left_reading = digitalRead(47);
 if (up_reading != last_up_state) {
  lastDebounceTime = millis();
  if ((millis() - lastDebounceTime) > debounce) {
   if (up_reading != up_state)
    up_state = up_reading;
   if (up_state == HIGH) {
    up_down++;
    if (up_down > 9)
     up_down = 0;
   }
  }
  last_up_state = up_reading;
  done = 1;
 }
 if (down_reading != last_down_state) {
  lastDebounceTime = millis();
  if ((millis() - lastDebounceTime) > debounce) {
   if (down_reading != down_state)
    down_state = down_reading;
   if (down_state == HIGH) {
    up_down--;
    if (up_down < 0)
     up_down = 9;
   }
  }
  last_down_state = down_reading;
  done = 1;
 }
 if (right_reading != last_right_state) {
  lastDebounceTime = millis();
  if ((millis() - lastDebounceTime) > debounce) {
   if (right_reading != right_state)
    right_state = down_reading;
   if (right_state == HIGH) {
    right_left++;
    if (right_left > 4)
     right_left = 0;
   }
  }
  last_right_state = right_reading;
  done2 = 1;
 }
 if (left_reading != last_left_state) {
  lastDebounceTime = millis();
  if ((millis() - lastDebounceTime) > debounce) {
   if (left_reading != left_state)
    left_state = left_reading;
   if (left_state == HIGH) {
    right_left--;
    if (right_left < 0)
     right_left = 4;
   }
  }
  last_left_state = left_reading;
  done2 = 1;
 }
}
void check_left_right() {
 switch (right_left) {
  case 0: {
    if (done2 == 1) {
     lcd.setCursor(4, 1);
     done2 = 0;
    }
    if (done == 1) {
     up_down = value[0];
     value[0] = up_down;
     lcd.print(up_down);
     done = 0;
    }
    break;
   }
  case 1: {
    if (done2 == 1) {
     lcd.setCursor(6, 1);
     done2 = 0;
    }
    if (done == 1) {
     up_down = value[2];
     value[2] = up_down;
     lcd.print(up_down);
     done = 0;
    }
    break;
   }
  case 2: {
    if (done2 == 1) {
     lcd.setCursor(7, 1);
     done2 = 0;
    }
    if (done == 1) {
     up_down = value[3];
     value[3] = up_down;
     lcd.print(up_down);
     done = 0;
    }
    break;
   }
  case 3: {
    if (done2 == 1) {
     lcd.setCursor(9, 1);
     done2 = 0;
    }
    if (done == 1) {
     up_down = value[5];
     value[5] = up_down;
     lcd.print(up_down);
     done = 0;
    }
    break;
   }
  case 4: {
    if (done2 == 1) {
     lcd.setCursor(10, 1);
     done2 = 0;
    }
    if (done == 1) {
     up_down = value[6];
     value[6] = up_down;
     lcd.print(up_down);
     done = 0;
    }
    break;
   }
 }
}
The "left_right" 0 - 4 control which case to chose, and the "up_down" then sets the numbers 0 - 9 I want in the correct place in the array.
Nothing works now, I have got both the left_right and up_ down to count up as is but in the sketch only left_right works (read worked) as intended.
Thanks!
Ragards Kevin