7 segment display + button

I have made a programm for a 7 segment display. Every time I push on the button, the display counts up. I think my programm is good but it doesn't work at my arduino. I don't see why. Could anyone help me?

Here is my programm

const int a = 2;
const int b = 3;
const int c = 4;
const int d = 5;
const int e = 6;
const int f = 7;
const int g = 8;
const int drukknop = 9;

int ktnu = 0;
int knopteller = 0;
int ktvorige= 0;

boolean zero(){
digitalWrite(a, HIGH);
digitalWrite(b, HIGH);
digitalWrite(c, HIGH);
digitalWrite(d, HIGH);
digitalWrite(e, HIGH);
digitalWrite(f, HIGH);
digitalWrite(g, LOW);
return true;}

boolean one(){
digitalWrite(a, LOW);
digitalWrite(b, HIGH);
digitalWrite(c, HIGH);
digitalWrite(d, LOW);
digitalWrite(e, LOW);
digitalWrite(f, LOW);
digitalWrite(g, LOW);
return true;}

boolean two(){
digitalWrite(a, HIGH);
digitalWrite(b, HIGH);
digitalWrite(c, LOW);
digitalWrite(d, HIGH);
digitalWrite(e, HIGH);
digitalWrite(f, LOW);
digitalWrite(g, HIGH);
return true;}

boolean three(){
digitalWrite(a, HIGH);
digitalWrite(b, HIGH);
digitalWrite(c, HIGH);
digitalWrite(d, HIGH);
digitalWrite(e, LOW);
digitalWrite(f, LOW);
digitalWrite(g, HIGH);
return true;}

boolean four(){
digitalWrite(a, LOW);
digitalWrite(b, HIGH);
digitalWrite(c, HIGH);
digitalWrite(d, LOW);
digitalWrite(e, LOW);
digitalWrite(f, HIGH);
digitalWrite(g, HIGH);
return true;}

boolean five(){
digitalWrite(a, HIGH);
digitalWrite(b, LOW);
digitalWrite(c, HIGH);
digitalWrite(d, HIGH);
digitalWrite(e, LOW);
digitalWrite(f, HIGH);
digitalWrite(g, HIGH);
return true;}

boolean six(){
digitalWrite(a, HIGH);
digitalWrite(b, LOW);
digitalWrite(c, HIGH);
digitalWrite(d, HIGH);
digitalWrite(e, HIGH);
digitalWrite(f, HIGH);
digitalWrite(g, HIGH);
return true;}

boolean seven(){
digitalWrite(a, HIGH);
digitalWrite(b, HIGH);
digitalWrite(c, HIGH);
digitalWrite(d, LOW);
digitalWrite(e, LOW);
digitalWrite(f, HIGH);
digitalWrite(g, LOW);
return true;}

boolean eight(){
digitalWrite(a, HIGH);
digitalWrite(b, HIGH);
digitalWrite(c, HIGH);
digitalWrite(d, HIGH);
digitalWrite(e, HIGH);
digitalWrite(f, HIGH);
digitalWrite(g, HIGH);
return true;}

boolean nine(){
digitalWrite(a, HIGH);
digitalWrite(b, HIGH);
digitalWrite(c, HIGH);
digitalWrite(d, LOW);
digitalWrite(e, LOW);
digitalWrite(f, HIGH);
digitalWrite(g, HIGH);
return true;}

boolean leeg(){
digitalWrite(a, LOW);
digitalWrite(b, LOW);
digitalWrite(c, LOW);
digitalWrite(d, LOW);
digitalWrite(e, LOW);
digitalWrite(f, LOW);
digitalWrite(g, LOW);
return true;}

void setup(){

pinMode(a, OUTPUT);
pinMode(b, OUTPUT);
pinMode(c, OUTPUT);
pinMode(d, OUTPUT);
pinMode(e, OUTPUT);
pinMode(f, OUTPUT);
pinMode(g, OUTPUT);
pinMode(drukknop, INPUT);

}
void loop(){
ktnu = digitalRead(drukknop);

if (ktnu != ktvorige) {
if (ktnu == HIGH) {

knopteller++;
Serial.println("aan");
Serial.print("aantal keren gedrukt: ");
Serial.println(knopteller);
} else {
Serial.println("uit");
}
delay(200);
}
int t = 1000;

switch (knopteller){
case 0: zero(); break;
case 1: one(); break;
case 2: two(); break;
case 3: three(); break;
case 4: four(); break;
case 5: five(); break;
case 6: six(); break;
case 7: seven(); break;
case 8: eight(); break;
case 9: nine(); break;
case 10: zero(); break;
}

}

Thank you

please enclose your code inside code tags

I honestly didn’t try your code but I have a couple hint for you.

  1. use interrupt with RISING and FALLING, this way you can check “when your button is being pressed”, instead of “if your button is being pressed right now”

 if (ktnu != ktvorige) {
   if (ktnu == HIGH) {

here you are checking if ktnu is different than 0 (meaning if the button is pressed, I suppose) and again checking if digitalRead is high. This is redundant.

  1. why int t = 1000, at the end of the main loop??

Try this for the Loop() portion of your code:

void loop() {

  delay(500);
  if (digitalRead(drukknop)) {
    knopteller++;
    if (knopteller > 9)
      knopteller = 0;
    Serial.println(knopteller);
  }

  switch (knopteller) {
    case 0: zero(); break;
    case 1: one(); break;
    case 2: two(); break;
    case 3: three(); break;
    case 4: four(); break;
    case 5: five(); break;
    case 6: six(); break;
    case 7: seven(); break;
    case 8: eight(); break;
    case 9: nine(); break;
    case 10: zero(); break;
  }
}

This assumes that pin 9 is HIGH to increment the counter. Two times per second the counter will increment when the button is pushed. Crude but it shows the logic required to detect the pushbutton on pin 9.

You do not need to test if a boolean variable is high like this:

if (pin == HIGH) { // true when pin == 1 }

this can be shortened to:

if (pin) { // true when pin == 1 }

If the test is for a LOW input:

if (!pin) { // true when pin == 0 }