I have LED Cube Project, and I want to activate the LED with My Android apps (Bluetooth). The LED Cube used A0-A5 and D0-D13 Pins, and the Bluetooth need RX and TX (D0, D1).

Where I can put the RX and TX (for Bluetooth HC-05) while D0, D1, and all analog and digital pins are used by the LED?

  • buy a Mega. perhaps a mini version
    – Juraj
    Commented Aug 2, 2018 at 7:22
  • is there no other way except buy a new device?
    – Rifky
    Commented Aug 2, 2018 at 7:38
  • You can't magic more pins out of thin air. If you have used all your pins you have used all your pins. You are already multiplexing, so you can't use that to reduce your pin usage. You may be able to use charlieplexing to free up some pins. We'd need to see your schematics to know what is possible. Or just get a bigger board. Get one with more power while you're at it - and multiple UARTs, so you can use hardware serial for bluetooth and debug over USB at the same time.
    – Majenko
    Commented Aug 2, 2018 at 8:54
  • my schematics just like LED Cube 4x4 in youtube youtube.com/watch?v=4pzxR-ZhbJA&t=548s
    – Rifky
    Commented Aug 2, 2018 at 9:58
  • 1
    4x4x4 is 64 leds. You can do that with 8x8, which is only 16 pins. The software should be changed, but that would be a good programming exercise.
    – Jot
    Commented Aug 2, 2018 at 14:45

1 Answer 1


You can't magic more pins out of thin air.

Yes you can!

You can have as many output (and even input) pins as you want. I managed to build 8x8x8 LED cube using ATTiny13 with just 6 output pins (using only 5 of them)

All it takes is a little extra coding and "shift registers". (For extending outputs use the one with "latch", but for LEDs normal one is enough)

CD4094 Top View

You can use three (for example CD4094) 8 bit shift registers. You connect three Arduino pins to "DATA" (a.k.a. SERIAL DATA INPUT) pin of each register. Then one Arduino pin to three "CLOCK" pins and one Arduino pin to three "OUTPUT ENABLE" pins.

Then in the code you send a sequence of bits into the registers simulating the clock signal and when that's over just set output enable to make the registers output a value on their 8 output pins each.

This way you use just 5 pins, and when you chain the registers together (last "Q8" pin of one register can go to "DATA" pin of second one) you can theoretically have as many outputs as you need at the cost of output update speed.

This way you can free most of your Arduino pins including TX and RX.

  • Using shift registers as extra parts is not "magic more pins out of thin air", but nontheless this is a valid answer how to get to the desired result.
    – chrisl
    Commented Aug 2, 2018 at 21:18
  • It's just semantics and abstraction, but I think using the shift registers in this particular fashion is called "extending number of outputs" of microcontroller. Thinking about it this way allows you to mentally "blackbox" the microcontroler with shift registers and just treat them as a single IC when designing rest of the circuit. Commented Aug 3, 2018 at 9:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.