Program game does not work on chip, whats wrong with program

/Ping pong, Version 1.0.9 Chip: Atmega 328P ( required parts wire Nine 220ohm resistor, Nine LEDs,
Two push buttons, and bread board) made April 24th, 2013. Point of the game is to score 5 point on opposing player,
you push the button once to block the net, and the light will bounce back from opposing player to other.
/

int Led1 = 8;//led 1 on digital pin 8//
int Led2 = 7;//led 2 on digital pin 7//
int Led3 = 6;//led 3 on digital pin 6//
int Led4 = 5;//led 4 on digital pin 5//
int Led5 = 3;//led 5 on digital pin 3//
int Led6 = 9;//led 6 on digital pin 9//
int Led7 = 10;//led 7 on digital pin 10//
int Led8 = 11;//led 8 on digital pin 11//
int Led9 = 12;//led 9 on digital pin 12//
int Button1 = 13;//button 1 on digital pin 13//
int Button2 = 4;//button 2 on digital pin 4//
int State1 = 0; // current state of the buttons //
int State2 = 0; // counter of number of button press //
int State11 = 0; // current state of the buttons //
int State22= 0; // counter of number of button press //
int State33 = 0;
int State44 = 0;
int FTL = 200; //delay for half a second//

void setup () { //set leds an buttonas output,and input//
pinMode(Led1, OUTPUT);
pinMode(Led2, OUTPUT);
pinMode(Led3, OUTPUT);
pinMode(Led4, OUTPUT);
pinMode(Led5, OUTPUT);
pinMode(Led6, OUTPUT);
pinMode(Led7, OUTPUT);
pinMode(Led8, OUTPUT);
pinMode(Led9, OUTPUT);
pinMode(Button1, INPUT);
pinMode(Button2, INPUT);
}

void loop () {
digitalWrite(Led5, HIGH);
delay(FTL);
digitalWrite(Led5, LOW);
delay(FTL);
digitalWrite(Led6, HIGH);
delay(FTL);
digitalWrite(Led6, LOW);
delay(FTL);
digitalWrite(Led7, HIGH);
delay(FTL);
digitalWrite(Led7, LOW);
delay(FTL);
digitalWrite(Led8, HIGH);

State33=0;
while(State33<1000) //check led, and button 1000 times//
{
State1 = digitalRead(Button2);// read the button state, and the next button state //
if (State1 == HIGH && Led8 == HIGH)break;
State33++;
}
if (State1 == HIGH && Led8 == HIGH)
{
digitalWrite(Led8, LOW);
delay(FTL);
digitalWrite(Led7, HIGH);
delay(FTL);
digitalWrite(Led7, LOW);
delay(FTL);
digitalWrite(Led6, HIGH);
delay(FTL);
digitalWrite(Led6, LOW);
delay(FTL);
digitalWrite(Led5, HIGH);
delay(FTL);
digitalWrite(Led5, LOW);
delay(FTL);
digitalWrite(Led4, HIGH);
delay(FTL);
digitalWrite(Led4, LOW);
delay(FTL);
digitalWrite(Led3, HIGH);
delay(FTL);
digitalWrite(Led3, LOW);
delay(FTL);
digitalWrite(Led2, HIGH);
}
else
{
digitalWrite(Led8, LOW);
delay(FTL);
digitalWrite(Led9, HIGH);// if not the ball move into net, and you press the restart button to begin the play again //
}

State44=0;
while(State44<1000)
{
State11 = digitalRead(Button1);// compare the button state to the last button state //
if (State11 == HIGH && Led2 == HIGH)break;
State44++;
}
if (State11 == HIGH && Led2 == HIGH) //if the button is pushed, and led 2 or the blocker is high, send the ball back to the other net //
{
delay(FTL);
digitalWrite(Led2, LOW);
delay(FTL);
digitalWrite(Led3, HIGH);
delay(FTL);
digitalWrite(Led3, LOW);
delay(FTL);
digitalWrite(Led4, HIGH);
delay(FTL);
digitalWrite(Led4, LOW);
delay(FTL);
digitalWrite(Led5, HIGH);
delay(FTL);
digitalWrite(Led5, LOW);
delay(FTL);
digitalWrite(Led6, HIGH);
delay(FTL);
digitalWrite(Led6, LOW);
delay(FTL);
digitalWrite(Led7, HIGH);
delay(FTL);
digitalWrite(Led7, LOW);
delay(FTL);
digitalWrite(Led8, HIGH);
}
else
{
digitalWrite(Led2, LOW);
delay(FTL);
digitalWrite(Led1, HIGH); // if not the ball move into net, and you press the restart button to begin the play again //
}
}

Led8 == HIGH

Led8=11, it does not create a magic reference to your pin, you need to use digitalRead to get the pin state

Also please format (ctrl+T in IDE) and post in code tags, it's a pain to try and read code like this

my teacher told me that you cannot digital read a pin set to ouput :astonished:

Forget code for a moment. Exactly how do you see your game playing out?

Seanflame: my teacher told me that you cannot digital read a pin set to ouput :astonished:

If your teacher meant it will not work, then he's wrong.

what do you mean by that like how the game will work

Yes. How does the game work?

start on the fifth led in the the middle, it starts blinking through the led 6, 7, 8 once it reaches the 8th led the player presses the button, and it sends the ball back to the opposing player, the other player has to do the same once the light reaches the 2nd led. If that dosen t happen the light will reach 9th led meaning the opposing player scored, other player the 1st led will light up

When you say "presses the button" do you mean press and hold it or press and release it? Could I, as a player simply hold the button down?

I can see your description in your code but would suggest that you rename some variables. "State22" might be better as "player2buttonCounter". Use descriptive variable names and use copy / paste to avoid typos and undeclared variable errors.

/Ping pong, Version 1.0.9 Chip: Atmega 328P ( required parts wire Nine 220ohm resistor, Nine LEDs,
Two push buttons, and bread board) made April 24th, 2013. Point of the game is to score 5 point on opposing player,
you push the button once to block the net, and the light will bounce back from opposing player to other.
/

int Led1 = 8;//led 1 on digital pin 8//
int Led2 = 7;//led 2 on digital pin 7//
int Led3 = 6;//led 3 on digital pin 6//
int Led4 = 5;//led 4 on digital pin 5//
int Led5 = 3;//led 5 on digital pin 3//
int Led6 = 9;//led 6 on digital pin 9//
int Led7 = 10;//led 7 on digital pin 10//
int Led8 = 11;//led 8 on digital pin 11//
int Led9 = 12;//led 9 on digital pin 12//
int Button1 = 13;//button 1 on digital pin 13//
int Button2 = 4;//button 2 on digital pin 4//
int State1 = 0; // current state of the buttons //
int State2 = 0; // counter of number of button press //
int State11 = 0; // current state of the buttons //
int State22= 0; // counter of number of button press //
int State33 = 0;
int State44 = 0;
int State3 = 0;
int State4 = 0;
int FTL = 200; //delay for half a second//

void setup () { //set leds an buttonas output,and input//
pinMode(Led1, OUTPUT);
pinMode(Led2, OUTPUT);
pinMode(Led3, OUTPUT);
pinMode(Led4, OUTPUT);
pinMode(Led5, OUTPUT);
pinMode(Led6, OUTPUT);
pinMode(Led7, OUTPUT);
pinMode(Led8, OUTPUT);
pinMode(Led9, OUTPUT);
pinMode(Button1, INPUT);
pinMode(Button2, INPUT);
}

void loop () {
digitalWrite(Led5, HIGH);
delay(FTL);
digitalWrite(Led5, LOW);
delay(FTL);
digitalWrite(Led6, HIGH);
delay(FTL);
digitalWrite(Led6, LOW);
delay(FTL);
digitalWrite(Led7, HIGH);
delay(FTL);
digitalWrite(Led7, LOW);
delay(FTL);
digitalWrite(Led8, HIGH);

State33=0;
while(State33<3000) //check led, and button 1000 times//
{
State11 = digitalRead(Button2);// read the button state, and the next button state //
State22 = digitalRead(Button2);
State3 = digitalRead(Led8);
State33++;
}
if (State11 == HIGH && State22 == HIGH && Led8 == HIGH) // button pused twice send ball back, to opposing player
{
digitalWrite(Led8, LOW);
delay(FTL);
digitalWrite(Led7, HIGH);
delay(FTL);
digitalWrite(Led7, LOW);
delay(FTL);
digitalWrite(Led6, HIGH);
delay(FTL);
digitalWrite(Led6, LOW);
delay(FTL);
digitalWrite(Led5, HIGH);
delay(FTL);
digitalWrite(Led5, LOW);
delay(FTL);
digitalWrite(Led4, HIGH);
delay(FTL);
digitalWrite(Led4, LOW);
delay(FTL);
digitalWrite(Led3, HIGH);
delay(FTL);
digitalWrite(Led3, LOW);
delay(FTL);
digitalWrite(Led2, HIGH);
}
else
{
digitalWrite(Led8, LOW);
delay(FTL);
digitalWrite(Led9, HIGH);// if not the ball move into net, and you press the restart button to begin the play again //
}

State44=0;
while(State44<3000)
{
State1 = digitalRead(Button1);// compare the button state to the last button state //
State2 = digitalRead(Button1);
State4 = digitalRead(Led2);
State44++;
}
if (State1 == HIGH && State2 == HIGH && Led2 == HIGH ) //if the button is pushed twice, and led 2 or the blocker is high, send the ball back to the other net //
{
delay(FTL);
digitalWrite(Led2, LOW);
delay(FTL);
digitalWrite(Led3, HIGH);
delay(FTL);
digitalWrite(Led3, LOW);
delay(FTL);
digitalWrite(Led4, HIGH);
delay(FTL);
digitalWrite(Led4, LOW);
delay(FTL);
digitalWrite(Led5, HIGH);
delay(FTL);
digitalWrite(Led5, LOW);
delay(FTL);
digitalWrite(Led6, HIGH);
delay(FTL);
digitalWrite(Led6, LOW);
delay(FTL);
digitalWrite(Led7, HIGH);
delay(FTL);
digitalWrite(Led7, LOW);
delay(FTL);
digitalWrite(Led8, HIGH);
}
else
{
digitalWrite(Led2, LOW);
delay(FTL);
digitalWrite(Led1, HIGH); // if not the ball move into net, and you press the restart button to begin the play again //
}
}

this is the revised version any problems you see?

Seanflame: this is the revised version any problems you see?

Not posted with code tags, and no use of the auto format tool to fix the complete lack of indenting.

I just created an account today I don’t now how to post it in code format

Seanflame: I just created an account today I don't now how to post it in code format

Then perhaps your should review the thread at the top entitled "How to use this forum - please read"

Please read the sticky note.. I got tired of that code after about 20 lines... I would have liked to help.. But

You haven't done anything to fix the problem:

if (State11 == HIGH && State22 == HIGH && Led8 == HIGH)

You are still using Led8 to try and check the state of the pin, the variable Led8=11, unless you specifically write otherwise.

Oh, I know exactly what your doing, I am making a pong game on my 20x4 LCD (very small game). Anyway, you need to use some IF statements and/or boolean operators. "Player1_Pressed" and "Player2_Pressed" You can also use 2 FOR loops to cycle through the LEDs.

Now in order for the game to work correctly, you want to keep track of the LEDs position. So lets say they are a total of 10 LEDs, well if the count for the LEDs is 1 and Player1_Pressed == false, player 2 gets a point. Likewise if the LED count is 10 and Player2_Pressed == false, player 1 gets a point. Now if the count for the LEDs is 1 and Player1_Pressed == true (they pressed the button), then switch to the other FOR loop (bounced back), and same for when Player2_Pressed == true.

It is really not that hard. I tell people just to think about what exactly they want to do, and break it down to simple lines of code. Writing it out on paper it a good way to visualize what it will look like, and adding comments on what you have solved so far is a big help.