7_segment_dispay

I'm new in the Arduino world and I want to make a counter with two common anode 7-segment displays. The wiring for the pushbutton I'm using is with pull-up resistors. The wiring I'm using is shown in the images. The wiring is fine, no problem with that, but I need help with the programming.

For this program, I used the code from section 5.3 of the Arduino Cookbook for the debounce function and the code from secction 7.11 of the same Cookbook. Everything went fine, the project can count from 00 to 99, but I wanted to count with every push, but it only counts when I press the button for certain time. I want that if I press the button, no matter how long, it only counts one time. If I press the button 5 times, it counts five times, no matter how fast I push the button. I've been trying a lot with the code, but I can't seem to make it right. I will really appreaciate the help. The code I'm using is below:

void Display_Segment(int);
int startPin=2;
int digit[10][7]={{0,0,0,0,0,0,1}, //Digit "0"
{1,0,0,1,1,1,1}, //Digit"1"
{0,0,1,0,0,1,0},//Digit"2"
{0,0,0,0,1,1,0},//Digit"3"
{1,0,0,1,1,0,0}, //Digit"4"
{0,1,0,0,1,0,0}, //Digit"5"
{0,1,0,0,0,0,0}, //Digit"6"
{0,0,0,1,1,1,1}, //Digit "7"
{0,0,0,0,0,0,0}, //Digit "8"
{0,0,0,0,1,0,0}}; //Digit"9"
const int ledPin = 10; //the number of LED pin
const int buttonPin = 11; // the number of the pushbutton
int ledState = LOW; //the current state of the output
int buttonState = LOW; //the current reding from the input pin
int lastButtonState = LOW; //the previuos reding from theinput pin
unsigned long lastDebounceTime = 0;//the last time the output pin was toggled
int debounceDelay = 50; // the debounce time; increase if the output flickersa
void setup() {
// seven segment pins as OUTPUT
for(int a=2 ;a<=8;a++){
pinMode(a,OUTPUT);
pinMode(buttonPin, INPUT_PULLUP);
digitalWrite(buttonPin, HIGH);
pinMode(ledPin, OUTPUT);
digitalWrite(ledPin, LOW); //set initial LED state
}
}
void loop() { //read the state of the switch into a local variable:

buttonState = digitalRead(buttonPin);
if (buttonState == HIGH && lastButtonState == LOW) { //indien knop werd ingedrukt EN dit is opgaande flank, start debounce
// reset the debunce timer
while (lastDebounceTime == 0) {
lastDebounceTime = millis();
}
if ((millis() - lastDebounceTime) > debounceDelay) //start debounce
{
while (buttonState != lastButtonState) //uitvoer zolang de knop nog ingedrukt is, en dus =1
{
buttonState = digitalRead (buttonPin);
}
lastButtonState = !buttonState; // wordt 1 zodra knop gelost is
}
}
if (buttonState == LOW && lastButtonState == HIGH) // enkel uitvoer op neergande flank EN nadat knop gelost werd EN na debounce
{
digitalWrite (ledPin, HIGH);
delay(500);
digitalWrite (ledPin, LOW);

for(int value =0;value<=9;value++)

{
delay(1000);
Display_Segment(value);// passing value to the function for displaying on segment
if ( value = value++ ){
value = 0;

}

}

delay(2500);

}

lastButtonState = buttonState; //alles terug naar begintoestand: 0
lastDebounceTime = 0;

}

void Display_Segment(int value){
{
int startPin=2;
for(int x=0;x<7;x++){
digitalWrite(startPin, digit[value][x]);
startPin++;

}
}
}

You posted this on the wrong forum section. Your post is clearly not an introductory tutorial, is it? You cannot have missed the sticky posts titled "I'M SERIOUS - DON'T PUT YOUR QUESTIONS HERE" etc.

I have reported this to the forum moderators who will move it to a more appropriate section, if they are feeling kind. If not, they may ban you from the forum for a few days. I would not blame them.

Please read the forum guide in the "read this" sticky post so you are aware of the forum rules and don't break any more, then modify your post above and add the code tags around your sketch. Also post a schematic, hand-drawn will be ok.

I'm new in the Arduino world

This is not an acceptable excuse for your actions. If you are unable to understand English, that would explain them, but clearly you do understand English.

PaulRB:
This is not an acceptable excuse for your actions. If you are unable to understand English, that would explain them, but clearly you do understand English.

Hmmm.

karim_m:
if (buttonState == LOW && lastButtonState == HIGH) // enkel uitvoer op neergande flank EN nadat knop gelost werd EN na debounce

One might wonder about that!

OK, first things first.

You need to go and read the forum instructions so that you can go back and modify your original post (not re-post it) - using the "More -> Modify" option below the right hand corner of your post - to mark up your code as such using the "</>" icon in the posting window. Just highlight each section of code (or output if you need to post that) from the IDE and click the icon.

In fact, the IDE has a "copy for forum" link to put these markings on a highlighted block for you so you then just paste it here in a posting window. But even before doing that, don't forget to use the "Auto-Format" (Ctrl-T) option first to make it easy to read. If you do not post it as "code" it can often be quite garbled and is always more difficult to read.

It is inappropriate to attach it as a ".ino" file unless it is clearly too long to include in the post proper. People can usually see the mistakes directly and do not want to have to actually load it in their own IDE. And that would also assume they are using a PC and have the IDE running on that PC.

Also tidy up your blank space. Do use blank lines, but only single blanks between complete functional blocks.