Dual 7 segment counters with triggers for adding & subtracting from 00 to 99

Hello,

I am working a project and I am trying to piece together a counter using my Uno. I have it wired 2-8 on segments A-G as so...

-A-
| |
F B
| |
-G-
| |
E C
| |
-D-

A = pin2
B = pin3
C = pin4
D = pin5
E = pin6
F = pin7
G = pin8

Anyways, I have butchered the hell out of some code but closest thing I found was a snippet of code that would count down automatically and one that used a trigger but the display did not work no matter how I tried to trace the program. So I am here posting for some help. If you can lead me to a few snippets that work I would be grateful. If you can figure this idea out and help me with the code I'll send beer.:slight_smile: God knows I need one.
Thanks for reading this and I hope someone out there enjoys a few cold ones :slight_smile:

Domasi

I Googled "7 segment Arduino tutorial" and got this example.
It probably is close to what you want.

That is close but it counts on it's own. I am looking for something that is triggered to increment or decrease by 1 for every signal sent to it.

:confused:

At the site in my signature block below there is code for a timer display that allows you to preset the value and then it counts down. You may be able to use some of the code for our own purposes.

Domasi,

this code will increment a 7Seg display from a blank display, to zero, then digits one through nine and back to blank display on the twelveth button press. Button connected to Arduino pin 12.

Connect Arduino pins as follows –

Pin 9 Segment Decimal Point
8 A
7 B
6 C
5 D
4 E
3 F
2 G

  // Code by Pedro147 Arduino Forum - Thanks to Grumpy Mike  http://www.thebox.myzen.co.uk/Tutorial/Arrays.html
  
  int pins [] = { 2, 3, 4, 5, 6, 7, 8, 9 };     // pin 9 allocated to DP but not used (first element of binary array in char elevenCode)
  int digit[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
  int switchPin = 12;                           // pushbutton attached to pin 12
  int buttonState = LOW;                        // initialise buttonState as LOW
  int counter = 0;                              // initialise counter as zero
  int timer1 = 100;                             // delay timer interval
  int timer = 1000;
  
   char elevenCode[] = {B00000000, B01111110, B00110000, B01101101, B01111001, B00110011, B01011011, B01011111, B01110000, B01111111, B01111011 };
  // Array element   #  No Display     0          1          2          3          4          5          6          7          8         9

   void setup()
  {
    for(int i = 0; i < 8; i++)                  // set digital pins as OUTPUTS
      pinMode(pins[i], OUTPUT); 
      pinMode(switchPin, INPUT);                // sets pin 12 as pushbutton INPUT 
  }
  
  
  void loop()
  {
    int newstate = digitalRead(switchPin);
    if (buttonState != newstate)                // has the state changed from  
                                                // HIGH to LOW or vice versa
  
    {                                          
    
      buttonState = newstate;
      if (newstate == LOW)                      // IF the button was pressed
        ++counter;                              // increment the counter by one
        delay(20);                              // delay to debounce
  
    }
  
    
    if(counter > 10)
      counter = 0;
      
      
    displayEleven(counter); 
  }
  
  
  void displayEleven(int num)
  {
    int mask = 1;
    for(int i = 0; i < 8; i++)
    {
      if((mask & elevenCode[num]) == 0)
        digitalWrite(pins[i], LOW); 
      else digitalWrite(pins[i], HIGH);
      mask = mask << 1;
    }
  }