Ruffsta,
you need to create some arrays and use the array contents to write to Mega Ports to drive the LEDs.
For example, say for each digit you connected g-f-e-d-c-b-a of the digit to say PL6-5-4-3-2-1-0
The first array would map a number to be displayed to the segments to make that number appear.
byte fontArray [] = {
0b00111111, // 0 not used-g-f-e-d-c-b-a, with 1 = segment on
0b00000110, // 1
0b01011011, // 2
0b01001111, // 3
etc.
};
with the segments arranged thusly:
a
f b
g
e c
d
[code]
Then to display a number, you look up the font for the digit to be displayed and send it to the port:
[code]
PORTL = fontArray[digit0];
PORTK = fontArray[digit1];
PORTF = fontArray[digit2];
PORTC = fontArray[digit3];
PORTB = fontArray[digit4];
PORTA = fontArray[digit5];
If you only have 3 digits, then just use 3 ports. Those ports all have 8 pins brought out to headers.
You will need a current limit resistor for each segment of the 7-segment display.
To read the 6 buttons, you can read the buttons individually, and act on them, with a little delay after reading, say 200mS so you could press & hold & count up or down 5 times a second:
void loop(){
if (digitalRead(button0) == LOW){ // assumes button0 is type INPUT_PULLUP and button connects pin to Gnd when pressed
if (digit0 > 0){ // check to not go below 0
digit0 = digit0 -1;
}
}
if digitalRead (button1) == LOW){
if (digit0 < 9){
digit0 =digit0 + 1; // check to not go above 9
}
}
PORTL = fontArray(digit0);
// repeat for the next digit or two
:
:
delay (200); // limit changes to 5 times a second
} // end of loop
You can see how even within that there is repetition, but there are only 3 digits so it's not too bad.
[/code]
[/code]