RAINBOW D20 ICOSAHEDRON Cube ... Under $20

by oldmaninSC in Circuits > Electronics

2947 Views, 65 Favorites, 0 Comments

RAINBOW D20 ICOSAHEDRON Cube ... Under $20

D20 icosahedron cube hand held
IMG_20220608_133046s.jpg
IMG_20220607_185209.jpg
IMG_20220608_133104s.jpg
IMG_20220608_133034s.jpg

'cube' will describe any geometric shape in this post.

Hi again, have you seen the MANY cubes presented on the internet? Wow they all have great displays, expensive electronics and complicated codes. So I made a super simple D20 Icosahedron cube.

It uses atmga8 (1/2 the pram of a 328) but any atmga 328 uno will work. It has a 3d folding case that you place 200 led into and solder. It is self contained with micro, battery, and charger. A detailed code the you can change the flashing to what ever you like. It has 2 flavors, desk stand or hand held. It turns on by a piezo sensor tap, then flashes, then goes to sleep. This works about 46 cycles before the battery is low. Then when taped a red flash comes on indicating the battery needs charging.

This should take about 4-6 hours to make not counting the 3d print time. Many of the components you probably already have.

This post will include my many mistakes so you won't make them and practical hints that will carry over to other projects.

Supplies

any uno ... nano/pro-mini/uno/atmel328 micro

3.7v 800ma drone battery https://www.amazon.com/dp/B08GZ3VZ82?

3.7v lipo charger https://www.amazon.com/dp/B00LTQU2RK?

200 or a reel WS2812B the best price I have found and great service https://www.aliexpress.com/item/2251832588193539.html?

piezo sensor or any pc switch https://www.amazon.com/dp/B07TF5Q74Z?

any p-ch mosfet can use n-ch but you need to change the circuit. The uno will NOT power the 200 leds

E6000 glue clear. best glue ever

THEORY of OPERATION

IMG_20220608_132802s.jpg
IMG_20220608_132836s.jpg
IMG_20220608_133111s.jpg
IMG_20220608_132955s.jpg

To make this cube or some helpful coding this will explain how the cube works.

The cube has 200 leds (ws2812b) that can be individually programed. A typical way to do this is to create an ARRAY in the code that has 200 places. Each place is 0 or 1. Then send the array to the leds and each led is on or off. Problematic if you just want led #157 to light. You have to have 199 zeros and one 1 at place 157 in the array. And this has to be done for each pattern display.

The next step would be to make an array for 20 triangles. Then each array pattern would be 20 long. With a way to turn in individual led inside the triangle. Poor idea again.

This cube ties the triangles into 4 groups of 5each. This makes 4 rows or just 4 places in an array. An array may look like const int spin[] = { row1, row2, row3, row4 };

This will send a decimal number to a row. Top, mid, mid-bottom, bottom.

Lets look at one pentagon. There are 5 triangles all tied together and act like one row. The leds inside the triangles are 10 each. I will call the 10 leds a,b,c,d,e,f,g,h,i,j. If you light up led # d then 5 leds in the pentagon will light up all at position d. same for the next 3 rows. This gives you the 4 rows in the spin[] array.

The 10 leds inside the triangles are addressed by bit shifting. here I use a 16 bit integer. ( int or unit16_t ). The triangles leds are from a front view...bottom right is A move left B-C-D step up E move right F-G step up H-I then at the top is J. See chart A.

(not the best text screen for this demonstration) .B000000......jihgfedcba (nothing on this line just trying to line things up)

If led # F is to light up the corresponding integer is B000000 0000100000 or 32 decimal. With bit shifting any led can be just a number See the chart. To light the center led (#F) the array spin[] { 32 } is all you need not a big 200 array.

A typical array is const int spin[]={ 32,32,32,32 }. This will light each row with the center led (#F) on. The cube will have 5 dots on top, 5 dots on mid, 5 dots on mid-bottom, 5 dots on bottom.

The array can be changed to { 32, 512, 512, 32 } This gives top-F, mid-J, mid-bottom-J, bottom-F.

To light more than one led just add the base numbers in the chart. Add 1 + 8 + 32+ 512 = 553 leds A, D, F, J

(green numbers in chart).

Leds off is just zero... { 32, 0, 0, 32 }

The arrays in the code have another feature that allows for a delay time and a repeat cycle. the first place in any array sets a delay time in mills. The second place sets the repeat cycle. In the code D20_328 here is an example

 const int allBlink[]={80,20, 1023,1023,1023,1023, 0,0,0,0, pend};

This will flash all leds in the 4 rows for 80 mills, then turn off leds for 80 mills, then repeat for 20 cycles or 10 blinks.

The pend tells the code to end and skip to the next array.

CLEAR as MUD ...

STL Files

Here are the stl for the cube. The freestanding cube has holes for the usb-charger. If you make the desktop use the Exact holes stl triangle to replace the triangles with slots. When gluing the stand make sure you alin the cube with the front just to look better. The desktop may need the pegs removed for the electronics. The big desktop fits a mirror I used in the James Webb mirrors...cheep from amazon. They are plastic and about $12 for 24.

I put packing tape on the large stl cube. When it gets folded this makes a firm tight bond. When you fold the separate pentagon glue it so it lays flat to keep the shape.

WORK ON THE PENTAGON FIRST

IMG_20220224_143515.jpg
IMG_20220607_110847.jpg
IMG_20220224_150200.jpg
IMG_20220225_165729.jpg
IMG_20220224_175523.jpg
IMG_20220224_175510.jpg
IMG_20220325_090929.jpg

You would think that pcbs would make this easy. If it was out sourced it may. I first tried with pcbs and cutting to just the right size, placing the leds perfectly, trying to get a soldering iron between the tight spaced leds, and then forming the ball took hours of time. Not to mention making 20 perfect pcbs. Then you have to paint. Wipe off the paint. This and the time to make the pcbs took more than 30 hours for one cube.

So I tried 3d prints. This made the leds easy to place but the leds do NOT have a marking on the bottom, like other leds do. So if I placed one out of order and wired it wrong the whole cube won't work. That is why I MARK the leds first.

I know this looks impossible but think of wiring just one triangle first. The plastic helps hold the wires in place so bare wire makes it easy. You will combine 5 triangles tying the inputs as one. This will give you 4 rows of 5 triangles.

I have a foldable 3d print of the top and bottom. Wire the leds as shown. My 3d prints changed to a diagonal to get the wiring easy. Start with the pentagon print for practice. Rotate it at each triangle to place and solder. I use plumbers flux and brush the metal tips of the leds. Then solder a pre tin blob on each leg. Then use bare copper wire to connect. The wire inside any lamp cord is good. I run the strands through fine sandpaper to get shinny so they solder easily. Wire as shown. Then jump with coated wire to connect the vccs, the grounds, and the inputs.

When finished wiring the pentagon you should test before folding. Now is the time to fix any leds that don't work. When folding the cube into shape the wires want to touch and bend inward into the fold (not good).

I have a simple test code that shows the full triangle and the last led #10.

BOTTOM HALF

IMG_20220324_144320 (2).jpg
IMG_20220324_144328.jpg
IMG_20220324_144334.jpg
IMG_20220325_084024.jpg
IMG_20220325_083833.jpg
IMG_20220325_083807.jpg
IMG_20220325_090935.jpg
IMG_20220607_175354.jpg

If you got the pentagon to work then move on to the bottom print. This works the same as the pentagon only 3 times more leds. The center of the pentagon is the input for the pwm nixi driver.

The triangle is the same all 20. The cube bundles them into 4 rows of 5 ea. The top is 5 triangles tied together, mid triangles, mid-bottom triangles, bottom triangle make up the 4 rows. You can see the pentagons easily but the long flat array of 10 is harder to picture. The triangles pointing down are the mid. The triangles pointing up are the mid-bottom. the attached pentagon is the top. The removed pentagon is the bottom. You fold the big structure to make a ball. The opening in the bottom allows for placement of the electronics. then you can wire the bottom to the ball. I let the cube play for a few days before I glue it shut.

INSTALL ELECTRONICS

IMG_20220607_113314.jpg
IMG_20220607_175613.jpg
IMG_20220607_175430.jpg
IMG_20220607_175342.jpg
IMG_20220607_110847.jpg

The electronics are easy. I soldered tiny wires to the usb connector and use a homemade ftdi adapter so I could change the code inside the cube but you will need to code the cube before closing it up. wire this with coated wire NOT bare. You may add a reset switch instead of the piezo sensor. A 5x5 standard push switch will fit into a led hole. This acts as a reset as well as a turn on. My piezo sensor needs to be trimmed to fit and you have to tap the right spot to wake the cube. I have a post about tiny mosfets that may help. A transistor will work but they draw 0.7 volts so you may need to increase the brite in the code

I have 2 types of cubes. One freestanding and one as a desktop. The desktop has miles more room for the electronics and even a switch if you like. Just run 3 wires from the cube to the stand inside. That is Vcc, ground, signal (pwm). The larger stand size is from a leftover mirror of the James Webb mirror I made (see instructable)

I wire the uno, charger, mosfet, and run wires to the cube. I test everything. Then I mount the charger in the ball and the uno on the one support. I check again. If ok I add the battery deep inside. I glue all the electronics with just a dab of E6000. The cube may not have a good shape and if you glue stuff inside it will make putting on the top harder. So I tape the bottom (separate pentagon) in place to get a good shape. when dry un-tape and complete connections to the bottom.

Downloads

CHANGING the CODE

The code works well. But you may get tired of the same sequence of flashings. I added a random start to the rainbow so the cube starts at a different color each time. But you may like a different sequence. So the basis of the code is to read an array full of numbers that make the leds light. Each array has 2 places at the front to determine delay and repeat times. The next numbers light the leds per bit place. The top of any triangle is 512. So 512 in array[3] lights the upper led. See the charts enclosed. Adding the numbers gives you those leds to light. You can make more arrays like const int allBlink[], const int lspin[], const int vvv[], etc. Then you put that new name into const int* allPatts[] with a comma at the end. the sketch will read each name from this array and send it to the leds.

Remember...there are 5 triangles to a row. Then 4 rows tied. Not 20 separate triangles. The code only sends out 4 packets per display...not 20 or 200. only 4 TOP, MID, MID-BOTTOM, BOTTOM. Each section has 50 leds tied so the whole display only counts to 4. Because the cube is in 4 sections and some opposite it looks like the leds are fired separately.

FINISH

IMG_20220608_133156s.jpg
IMG_20220607_175206.jpg
IMG_20220607_175226.jpg

You can see my pcb made cubes. They look drab next to the 3d layouts. Leds NEVER photograph well. I tried 4 phone cameras and they still don't show good colors. To hold one of these in your hand is really cool.

THANKS FOR VIEWING....but you really need to make this.