BCD score keeper

Hi all. I’m making a lazer shooting arcade game. It’s controlled by a Mega32. I am using 2-7 segment LEDs and BCD decoders to keep score. I cannot figure out how to write the code that will reference the score, add 1, and write it to the 8 pins of the BCD ICs. PLEASE HELP!

We need to see your hardware design schematic.
also
Please, you must show us your complete sketch. Attach your code using the </> icon on the left side of the posting menu.
Put your sketch between the code tags [code][/code]

Lazergamer69: Hi all. I'm making a lazer shooting arcade game. It's controlled by a Mega32. I am using 2-7 segment LEDs and BCD decoders to keep score. I cannot figure out how to write the code that will reference the score, add 1, and write it to the 8 pins of the BCD ICs. PLEASE HELP!

The score should be in a variable somewhere in your code. You wrote the code, so you should know which variable has the score.

To add one to it:

score = score + 1;

substitute the name of the variable holding the score where I wrote "score"

Then write that out to the BCD chip. How is something only you can answer since only you know which BCD chip you have.

Here is the code that set the score, add 1, and write it to the 8 pins of the BCD ICs.

void loop()
{
  unsigned int score, score_bcd;

  score = score + 1;

  score_bcd = uint2bcd(score);
}


static unsigned int uint2bcd(unsigned int ival)
 {
 	return ((ival / 10) << 4) | (ival % 10);  // for ival < 100
 }

BillHo:
Here is the code that set the score, add 1, and write it to the 8 pins of the BCD ICs.

void loop()

{
  unsigned int score, score_bcd;

score = score + 1;

score_bcd = uint2bcd(score);
}

static unsigned int uint2bcd(unsigned int ival)
{
return ((ival / 10) << 4) | (ival % 10);  // for ival < 100
}

Since score is local to loop it will lose its value every time loop rolls over. So your score will always be 1.

I don’t see where this writes anything to any pins.