# Hi ,need help

I have a homework I designed 0-99 counters but our teacher tried a lot of things that I wanted to increase it with a button but I could not code the button I could help you find the wrong place

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 dp=9;
const int konlar=10;
const int kbirler=11;
const int but=12;
int sayici;

void setup() {
if (butondurumu==0)
{sayici=sayici+1;}

for(int i=2;i<12;i++)
{delay(100);
pinMode(i,OUTPUT);
}
pinMode(but,INPUT_PULLUP);
sayici=0;
}

void loop() {
int birler=sayici%10;
int onlar=sayici/10;
int i=0;
while(i<35)
{
goster(birler);
digitalWrite(kbirler,HIGH);
digitalWrite(konlar,LOW);
//delay(10);
goster(onlar);
digitalWrite(kbirler,LOW);
digitalWrite(konlar,HIGH);
//delay(10);
//i++;
}
//sayici++;

if (sayici==100)
sayici=0;

}
void goster(int n)
{
switch(n)
{
case 0:
digitalWrite(a,HIGH);
digitalWrite(b,HIGH);
digitalWrite(c,HIGH);
digitalWrite(d,HIGH);
digitalWrite(e,HIGH);
digitalWrite(f,HIGH);
digitalWrite(g,LOW);
break;
case 1:
digitalWrite(a,LOW);
digitalWrite(b,HIGH);
digitalWrite(c,HIGH);
digitalWrite(d,LOW);
digitalWrite(e,LOW);
digitalWrite(f,LOW);
digitalWrite(g,LOW);
break;
case 2:
digitalWrite(a,HIGH);
digitalWrite(b,HIGH);
digitalWrite(c,LOW);
digitalWrite(d,HIGH);
digitalWrite(e,HIGH);
digitalWrite(f,LOW);
digitalWrite(g,HIGH);
break;
case 3:
digitalWrite(a,HIGH);
digitalWrite(b,HIGH);
digitalWrite(c,HIGH);
digitalWrite(d,HIGH);
digitalWrite(e,LOW);
digitalWrite(f,LOW);
digitalWrite(g,HIGH);
break;
case 4:
digitalWrite(a,LOW);
digitalWrite(b,HIGH);
digitalWrite(c,HIGH);
digitalWrite(d,LOW);
digitalWrite(e,LOW);
digitalWrite(f,HIGH);
digitalWrite(g,HIGH);
break;
case 5:
digitalWrite(a,HIGH);
digitalWrite(b,LOW);
digitalWrite(c,HIGH);
digitalWrite(d,HIGH);
digitalWrite(e,LOW);
digitalWrite(f,HIGH);
digitalWrite(g,HIGH);
break;
case 6:
digitalWrite(a,HIGH);
digitalWrite(b,LOW);
digitalWrite(c,HIGH);
digitalWrite(d,HIGH);
digitalWrite(e,HIGH);
digitalWrite(f,HIGH);
digitalWrite(g,HIGH);
break;
case 7:
digitalWrite(a,HIGH);
digitalWrite(b,HIGH);
digitalWrite(c,HIGH);
digitalWrite(d,LOW);
digitalWrite(e,LOW);
digitalWrite(f,LOW);
digitalWrite(g,LOW);
break;
case 8:
digitalWrite(a,HIGH);
digitalWrite(b,HIGH);
digitalWrite(c,HIGH);
digitalWrite(d,HIGH);
digitalWrite(e,HIGH);
digitalWrite(f,HIGH);
digitalWrite(g,HIGH);
break;
case 9:
digitalWrite(a,HIGH);
digitalWrite(b,HIGH);
digitalWrite(c,HIGH);
digitalWrite(d,HIGH);
digitalWrite(e,LOW);
digitalWrite(f,HIGH);
digitalWrite(g,HIGH);
break;
}

}

Please use code tags (</> button on the toolbar) when you post code or warning/error messages. The reason is that the forum software can interpret parts of your code as markup, leading to confusion, wasted time, and a reduced chance for you to get help with your problem. This will also make it easier to read your code and to copy it to the IDE or editor. Using code tags and other important information is explained in the How to use this forum post. Please read it.

Please always do a Tools > Auto Format on your code before posting it. This will make it easier for you to spot bugs and make it easier for us to read.

``````void setup() {
if (butondurumu == 0)
{
sayici = sayici + 1;
}

for (int i = 2; i < 12; i++)
{ delay(100);
pinMode(i, OUTPUT);
}
pinMode(but, INPUT_PULLUP);
sayici = 0;
}
``````

You need to set the pinMode of the button before doing the digitalRead.

You need to understand that setup() only runs once when you first start the program running. So if you want the code to react to button presses after that time you will need to move your code that reads the button to loop().

You may want to learn about debouncing your button input. See File > Examples > 02.Digital > Debounce and https://www.arduino.cc/en/Tutorial/Debounce.

I thank you for the information you provided I am new to these topics I see the course for about 1 month I would like to thank you again

Why do you start a new post??