digital array

I am trying to troubleshoot with a student who is trying to learn how to use a 7 segment display. He has the display working (he can input a number into the code, and it will display on the screen fine), but things go haywire when he tried to introduce a button.
Just trying something simple, to make a "3" appear when a button is pushed, and a "2" when it isn't. However, when ever the button is pushed, the whole arduino and setup goes blank and loses power. It might be a wiring issue (I haven't taken a close look), but I wanted to run the code past to see if we are missing something. Below is the code for you to take a look at. I will also post a picture of the circuit, in case you are a wiring ninja and can spot an issue there.

int aPin = 2;  //            A
int bPin = 3;  //        ________
int cPin = 4;  //       |        |
int dPin = 5;  //     F |        | B
int ePin = 6;  //       |   G    | 
int fPin = 7;  //       |________|
int gPin = 8;  //       |        |
int GND1 = 9;  //       |        |
int GND2 = 10; //     E |        | C
int GND3 = 11; //       |________|
int GND4 = 12; //       
int num;       //           D
int dig1 = 0;
int dig2 = 0;
int dig3 = 0;
int dig4 = 0;
int DTime = 4;

int btn = 13;

void setup()
{ 
  pinMode(aPin, OUTPUT);
  pinMode(bPin, OUTPUT);
  pinMode(cPin, OUTPUT);
  pinMode(dPin, OUTPUT);
  pinMode(ePin, OUTPUT); 
  pinMode(fPin, OUTPUT);
  pinMode(gPin, OUTPUT);
  pinMode(GND1, OUTPUT);
  pinMode(GND2, OUTPUT);
  pinMode(GND3, OUTPUT);
  pinMode(GND4, OUTPUT);
  Serial.begin(9600);
  pinMode(btn, INPUT_PULLUP);
}
void loop()
{
  digitalWrite( GND1, HIGH);
  digitalWrite( GND2, HIGH);
  digitalWrite( GND3, HIGH);
  digitalWrite( GND4, HIGH);

if(digitalRead(btn) == LOW)
{
  dig1 = 3;
  delay(5000);
}else{
  dig1 = 2;
}

 Serial.print(digitalRead(btn));

 
if (Serial.available() > 0)
{
  num = Serial.parseInt();
  Serial.println(num);
  dig1 = num / 1000;
  num = num - (dig1 * 1000);
  dig2 = num / 100;
  num = num - (dig2 * 100);
  dig3 = num / 10;
  dig4 = num - (dig3 *10);
}
 
  digitalWrite( GND4, LOW);   //digit 4
  pickNumber(dig4);
  delay(DTime);
  digitalWrite( GND4, HIGH);
 
  digitalWrite( GND3, LOW);   //digit 3
  pickNumber(dig3);
  delay(DTime);
  digitalWrite( GND3, HIGH);
 
  digitalWrite( GND2, LOW);   //digit 2
  pickNumber(dig2);
  delay(DTime);
  digitalWrite( GND2, HIGH);
 
  digitalWrite( GND1, LOW);   //digit 1
  pickNumber(dig1);
  delay(DTime);
  digitalWrite( GND1, HIGH);

}
 
void pickNumber(int x){
   switch(x){
     case 1:  one(); break;
     case 2:  two(); break;
     case 3:  three(); break;
     case 4:  four(); break;
     case 5:  five(); break;
     case 6:  six(); break;
     case 7:  seven(); break;
     case 8:  eight(); break;
     case 9:  nine(); break;
     case 10: down(); break;
     case 11: mid(); break;
     case 12: up(); break;
     case 13: downMid(); break;
     case 14: midUp(); break;
     case 15: downMidUp; break;
     default: zero(); break;
   }
}

void clearLEDs()
{  
  digitalWrite(  2, LOW); // A
  digitalWrite(  3, LOW); // B
  digitalWrite(  4, LOW); // C
  digitalWrite(  5, LOW); // D
  digitalWrite(  6, LOW); // E
  digitalWrite(  7, LOW); // F
  digitalWrite(  8, LOW); // G
}

void one()
{
  digitalWrite( aPin, LOW);
  digitalWrite( bPin, HIGH);
  digitalWrite( cPin, HIGH);
  digitalWrite( dPin, LOW);
  digitalWrite( ePin, LOW);
  digitalWrite( fPin, LOW);
  digitalWrite( gPin, LOW);
}

void two()
{
  digitalWrite( aPin, HIGH);
  digitalWrite( bPin, HIGH);
  digitalWrite( cPin, LOW);
  digitalWrite( dPin, HIGH);
  digitalWrite( ePin, HIGH);
  digitalWrite( fPin, LOW);
  digitalWrite( gPin, HIGH);
}

void three()
{
  digitalWrite( aPin, HIGH);
  digitalWrite( bPin, HIGH);
  digitalWrite( cPin, HIGH);
  digitalWrite( dPin, HIGH);
  digitalWrite( ePin, LOW);
  digitalWrite( fPin, LOW);
  digitalWrite( gPin, HIGH);
}

void four()
{
  digitalWrite( aPin, LOW);
  digitalWrite( bPin, HIGH);
  digitalWrite( cPin, HIGH);
  digitalWrite( dPin, LOW);
  digitalWrite( ePin, LOW);
  digitalWrite( fPin, HIGH);
  digitalWrite( gPin, HIGH);
}

void five()
{
  digitalWrite( aPin, HIGH);
  digitalWrite( bPin, LOW);
  digitalWrite( cPin, HIGH);
  digitalWrite( dPin, HIGH);
  digitalWrite( ePin, LOW);
  digitalWrite( fPin, HIGH);
  digitalWrite( gPin, HIGH);
}

void six()
{
  digitalWrite( aPin, HIGH);
  digitalWrite( bPin, LOW);
  digitalWrite( cPin, HIGH);
  digitalWrite( dPin, HIGH);
  digitalWrite( ePin, HIGH);
  digitalWrite( fPin, HIGH);
  digitalWrite( gPin, HIGH);
}

void seven()
{
  digitalWrite( aPin, HIGH);
  digitalWrite( bPin, HIGH);
  digitalWrite( cPin, HIGH);
  digitalWrite( dPin, LOW);
  digitalWrite( ePin, LOW);
  digitalWrite( fPin, LOW);
  digitalWrite( gPin, LOW);
}

void eight()
{
  digitalWrite( aPin, HIGH);
  digitalWrite( bPin, HIGH);
  digitalWrite( cPin, HIGH);
  digitalWrite( dPin, HIGH);
  digitalWrite( ePin, HIGH);
  digitalWrite( fPin, HIGH);
  digitalWrite( gPin, HIGH);
}

void nine()
{
  digitalWrite( aPin, HIGH);
  digitalWrite( bPin, HIGH);
  digitalWrite( cPin, HIGH);
  digitalWrite( dPin, HIGH);
  digitalWrite( ePin, LOW);
  digitalWrite( fPin, HIGH);
  digitalWrite( gPin, HIGH);
}

void zero()
{
  digitalWrite( aPin, HIGH);
  digitalWrite( bPin, HIGH);
  digitalWrite( cPin, HIGH);
  digitalWrite( dPin, HIGH);
  digitalWrite( ePin, HIGH);
  digitalWrite( fPin, HIGH);
  digitalWrite( gPin, LOW);
}

void down()
{
  digitalWrite( aPin, LOW);
  digitalWrite( bPin, LOW);
  digitalWrite( cPin, LOW);
  digitalWrite( dPin, HIGH);
  digitalWrite( ePin, LOW);
  digitalWrite( fPin, LOW);
  digitalWrite( gPin, LOW);
}

void mid()
{
  digitalWrite( aPin, LOW);
  digitalWrite( bPin, LOW);
  digitalWrite( cPin, LOW);
  digitalWrite( dPin, LOW);
  digitalWrite( ePin, LOW);
  digitalWrite( fPin, LOW);
  digitalWrite( gPin, HIGH);
}

void up()
{
  digitalWrite( aPin, HIGH);
  digitalWrite( bPin, LOW);
  digitalWrite( cPin, LOW);
  digitalWrite( dPin, LOW);
  digitalWrite( ePin, LOW);
  digitalWrite( fPin, LOW);
  digitalWrite( gPin, LOW);
}

void downMid()
{
  digitalWrite( aPin, LOW);
  digitalWrite( bPin, LOW);
  digitalWrite( cPin, LOW);
  digitalWrite( dPin, HIGH);
  digitalWrite( ePin, LOW);
  digitalWrite( fPin, LOW);
  digitalWrite( gPin, HIGH);
}

void midUp()
{
  digitalWrite( aPin, HIGH);
  digitalWrite( bPin, LOW);
  digitalWrite( cPin, LOW);
  digitalWrite( dPin, LOW);
  digitalWrite( ePin, LOW);
  digitalWrite( fPin, LOW);
  digitalWrite( gPin, HIGH);
}

void downMidUp()
{
  digitalWrite( aPin, HIGH);
  digitalWrite( bPin, LOW);
  digitalWrite( cPin, LOW);
  digitalWrite( dPin, HIGH);
  digitalWrite( ePin, LOW);
  digitalWrite( fPin, LOW);
  digitalWrite( gPin, HIGH);
}

Sure. The switch connects 5V and ground when it's pushed.

If you are the teacher, you really, really, really, need to be teaching schematic drawing.

He went home with his schematics, I'm sticking around to try and figure it out.
Sorry, the picture was wrong. He had rewired to try a "buttonState" code. Here is the picture of the situation described.

Try removing the "delay(5000);" from loop().

Does the display have build-in resistors? If not, you're in the process of blowing the Arduino pins.

The code also uses digital pins as 'grounds' (to be able to switch a digit on or off). That means that with multiple segments lit (worse case the number 8 plus dot), the total current will more than likely be too high for that pin (safe maximum is 20mA, absolute maximum 40mA).

Also pay attention to the maximum current that can flow through the Vcc and GND pins of the micro (200mA).

sterretje:
Does the display have build-in resistors? If not, you're in the process of blowing the Arduino pins.

The code also uses digital pins as 'grounds' (to be able to switch a digit on or off). That means that with multiple segments lit (worse case the number 8 plus dot), the total current will more than likely be too high for that pin (safe maximum is 20mA, absolute maximum 40mA).

Also pay attention to the maximum current that can flow through the Vcc and GND pins of the micro (200mA).

That could be it. No, there is no resistors involved, I will have him put some one.
Is there a better way to wire one of these arrays in order to prevent it from maxing out?

Use transistors to switch the common pin of each digit.

sterretje:
Use transistors to switch the common pin of each digit.

I don't want to ask too much, but do you happen to have a schematic/detailed directions how to do this? I'm a chemistry teacher teaching a microcontrollers class with the goal of learning it myself and giving students an opportunity to learn programming and electronics, and I'm not familiar with transistor wiring.
Thanks

I'll draw you one - standby.

Here you go.
LED resistors: (5V - 2.2V - 0.7V)/.01A = 210 ohm. Check Vf of the LEDs in use and adjust accordingly.
2.2V = Vf of LED, 2.2V typical for Red
0.7V = Vce of NPN transistor, could be 0.5 to 0.7V.

NPN resistors: (5V - 0.7V)/.015 = 287 ohm. Standard 270 ohm will be fine.
(5V - 0.7V)/270ohm = 15.9mA
0.7V = Vbe of transistor.

5V coming from Arduino can vary also, may be as low as 4.2V at high loads and a low Vusb from a PC for example.
[Edit - replaced drawing for smarter use of LED resistors]

Drawn for my convenience to use pins that didn't a lot of criss-crossing. The 11 outputs can be what ever you want to use.
www.expresspcb.com has free schematic capture for making up things like that pretty quick.
I can send you some symbols if you need them.