Author Options:

Arduino programming loop help? Answered

i am making a tic tac toe game. I have two sets of 9 leds. one set for player one and another for player 2. I have 4 pushbuttons 2 for each player. when i push 1 of the buttons i want the first led to light up then when i press it again the second led would light up ant the first would stop then if i would press the second button then it would keep the second led on and then i could choose another led while the first led i chose is still on. this is my code so far but ineed help on my loop any help is appreciated also in my code pbcp1 means pushbutton cursor player 1 and pbsp1 means pushbutton select player1. if it ends in 2 instead of one then it is just for player 2. Thanks in advance.

int pbcp1 = 13;
int pbsp1 = 12;
int pbcp2 = 11;
int pbsp2 = 10;
int greenled1 = 22;
int greenled2 = 24;
int greenled3 = 26;
int greenled4 = 28;
int greenled5 = 30;
int greenled6 = 32;
int greenled7 = 34;
int greenled8 = 36;
int greenled9 = 38;
int redled1 = 23;
int redled2 = 25;
int redled3 = 27;
int redled4 = 29;
int redled5 = 31;
int redled6 = 33;
int redled7 = 35;
int redled8 = 37;
int redled9 = 39;

void setup() {               
  pinMode(greenled1, OUTPUT);
  pinMode(greenled2, OUTPUT);
  pinMode(greenled3, OUTPUT);
  pinMode(greenled4, OUTPUT); 
  pinMode(greenled5, OUTPUT);
  pinMode(greenled6, OUTPUT); 
  pinMode(greenled7, OUTPUT);
  pinMode(greenled8, OUTPUT);
  pinMode(greenled9, OUTPUT);
  pinMode(redled1, OUTPUT);
  pinMode(redled2, OUTPUT);
  pinMode(redled3, OUTPUT);
  pinMode(redled4, OUTPUT); 
  pinMode(redled5, OUTPUT);
  pinMode(redled6, OUTPUT);
  pinMode(redled7, OUTPUT);
  pinMode(redled8, OUTPUT);
  pinMode(redled9, OUTPUT);
  pinMode(pbcp1, INPUT);
  pinMode(pbsp1, INPUT);
  pinMode(pbsp2, INPUT);
  pinMode(pbcp2, INPUT); 

void loop() {




The forums are retiring in 2021 and are now closed for new topics and comments.

7 years ago

There is nothing here for anyone to help you with. You actually need to have some code and some problems with how the code is running for someone to help. Looks like you need to actually learn to program the arduino.

Go to the arduino web site and start going through the tutorials. Once you get a good understanding of some of the basics like Debounce, you'll be ready to start programming your game.