Need help coding a nerf ammo counter

Hi. I'm new to this forum.
I need some help coding a nerf ammo counter. My plan is to have 2 seven segments connected to an arduino, and 5 buttons. One to count down. One to change number to 18. Another to change it to 12. Another to change to 6. And one more to reset (reload) the count. I need some help with the setup and coding.
Thank you
Tim

What do you have so far? Do you have a seven segment display? Have you hooked it up?

Have you looked at:
http://playground.arduino.cc/Main/SevenSegmentLibrary#.UxC0vPng7m4

At the moment I have one display hooked up I'm trying to at least turn individual segments on but that's not working.
seg a to 13. B to 12. C to 11. D to 10. E to 9. F to 8. And g to 7. I only have one switch hooked up because I am just trying to turn in the individual segments connected to pin 6.

That's for one that will count down on a timer. I want it to count down with a button press.

I intended for that to be about hooking it up.

They are suggesting (Arduino pin, 7 segment pin)
2 7 (A)
3 6 (B)
4 4 (C)
5 2 (D)
6 1 (E)
7 9 (F)
8 10 (G)
9 5 (DP)

You seem to have
13 A
12 B
11 C
10 D
9 E
8 F
7 G.
and then something about a 6.

You can worry about the coding and counting after you get the display working

I've got the display working. It just won't activate individual segments with pressing a button.

I'm afraid I don't follow. It's working but it doesn't activate tells me almost nothing.

Perhaps you could lay the whole thing out. You have buttons? Where might they be? You have a schematic of your current hookup? Is this a coding issue only?

Yeah the hardware is fine. It's just the coding.

Oh. The kind of code you could post on a forum? Like this one? Using code tags?

I don't have a code yet. That's why I came to this forum.

Well, write some and then we'll help you with it.

It just won't activate individual segments with pressing a button.

So, no code, but you are gleefully pressing a button anyway hoping something will happen?

I don't think we have the whole picture.

No I had a code but it didn't work.

Okay. Well, you have fun with that.

Hi, have you any programming experience, electronics and hardware experience.

Try the sketch in the tutorial you were shown, get it running to understand how it works.
Don't dismiss it because it instantly doesn't do what you need.

Tom........ :slight_smile:

I don't really have any programming experience. And I will try that tutorial. It's just that I'm away for the weekend without my computer and that's where my code and components are.

Here is the code I had.

int buttonPin = 6; 
int count = 6;
int buttonState = 0;

void setup() 
{ 
  DDRB = B11111111; // sets D13~D8 to output
  DDRD = B10000000; // sets D7 to output, D6~D0 to input
}

void loop() 
{ 
  buttonState = digitalRead(buttonPin); // read D6

  if (buttonState == HIGH) 
  {
    count--;
  }
  //
  // delay here for debouncing purposes
delay(100)
  //
  if (count>= 6) 
  { 
    PORTB = B11111111;
  }

  if (count>= 5) 
  { 
    PORTB = B11111110;
  } 
  if (count>= 4) 
  { 
    PORTB = B11111100; 
  } 
  if (count>= 3) 
  { 
    PORTB = B11111000;
  } 
  if (count>= 2) 
  { 
    PORTB = B11110000;
  } 
  if (count>= 1) 
  { 
    PORTB = B11100000;
  } 
  if (count>= 0) 
  { 
    PORTB = B11000000;
  } 
}
delay(100)

Oops.

What happened to the code tags?

Sorry please excuse me. What are code tags?

timanderson6:
What are code tags?

Read here, § #7:
http://forum.arduino.cc/index.php/topic,148850.0.html