LED Cube 3x3x3 Button Switch Off/On and 9V battery

Hello, I'm newbie in Arduino Uno and my questions maybe does not make any sense but I'm struggeling with using button to switch my LED Cube off/on. Since I'm not using pins for 5V and my PWM pins are full I don't know how to use it and connect it. :o

Also, I wish I would know the anwer of: if I connect my powerbank to USB port everything works just fine although if I connect 9V battery to external power supply (DC jack) after some time (half of hour) the one site of cube get stuck (just 3leds are lighted up, no more effects). Why is that?

Here is the scheme:

Please don't hate me and thank you in advance for your help :slight_smile: !

@marosm's schematic:

You can use any of those unused analog pins (A0-A5) as digital inputs for the switch. Despite the name, these can be used as regular digital pins (e.g., digitalRead(), digitalWrite()). They just have the additional attribute of being analog inputs.

marosm:
Also, I wish I would know the answer of: if I connect my powerbank to USB port everything works just fine although if I connect 9V battery to external power supply (DC jack) after some time (half of hour) the one site of cube get stuck (just 3leds are lighted up, no more effects). Why is that?

If you are using a 9 V "PP3" battery, it is likely that the battery is going flat after half an hour.

Powering Arduinos by the "barrel jack" or "Vin" is a bad idea if you are actually drawing current from the "5V" pin or many LEDs. Nine LEDs at 20 mA would be 180 mA though with those 220 Ohm resistors you are drawing a maximum more like 120 mA.

Power supply aside, the sensible way to make a 4 by 4 by 5 cube (of which a 3 by 3 by 3 is a subset) is to use a MAX7219. :grinning:

I'm getting to it slowly :slight_smile: I think I'll watch some tutorials about arduino, because lot's of things makes me confused

Thank you for your answer guys! Helpful