Introduction: 3x3x3 LED Cube With Bluetooth (Android)

This is a guide to make your own 3x3x3 Bluetooth controlled LED cube

It all started about 2 years ago when i was in 7th Grade when I joined an electronics workshop where I was introduced to basic electronics like what is resistor, capacitor, diode, how to solder and other stuff and I started my first few electronics projects like a light sensitive switch, clap switch, etc. Then after some time I heard about Arduino. I was told that this is an amazing platform from which I could take my projects to a whole new level. I then started exploring about Arduino through internet I didn’t join any class, my only source of learning about Arduino was through googling and when I was familiar with it I brought my first Arduino. This changed how I used to look at electronics and made my first few Arduino projects.

I liked the concept of LED cubes and wanted to make one. To begin I made a 2x2x2 LED cube then I thought that it was boring that the cube isn’t in your control it runs the same program again and again. So I decided to make a 3x3x3 LED cube with Bluetooth. I am giving a large amount of detail in this instructable.

So in this instructable I will teach you how to build this amazing project.

Step 1: Skills

For this project there are few things you should know such

as-

· Basic electronics

· Soldering

· Programming (In Arduino IDE)

Step 2: Components and Tools

These are the things you will require for this project-

Components-

Tools-

  • PC
  • Soldering iron
  • Wire cutter
  • Drill machine
  • Hot Glue
  • Sand paper

Step 3: Get the Components

You may buy Arduino UNO from Spark-fun or Digi-Key or from

original Arduino site.

Spark fun R3

Spark fun R3 SMD

Digi-Key

And you will get genuine boards but the disadvantage is their cost. I recommend getting Arduino clones instead, they function properly as the main microcontroller (ATmega328p) for both the original and clone is the same. You can buy LEDs, resistors, and other parts from local electronics store for cheap or online.

Step 4: What Is a LED Cube?

A LED cube is a three dimensional arrangement of LEDs. Think of it as many LED matrixes stacked one above the other forming a cuboidal structure. It enables you to see in three dimensions and get some depth perception.

Every LED is individually controlled, so you can show amazing patterns on the cube.

You can get creative and make your own patterns.

Step 5: How a LED Cube Works?

LED Cubes are much more complex than LED matrixes. In a 5x5 LED matrix there are 25 LEDs in total whereas in a 5x5x5 LED cube there are 125 LEDs which are to be individually controlled, hence it gets even more complex with bigger cubes and if you want it to be RGB then it gets worse that is 3x 5x5x5 = 375 LEDs! No microcontroller has this many IO pins.

So we use the technic of multiplexing. You know that a LED should be provided positive voltage at one pin and negative voltage at the other. So we divide the cube into layers and columns (see in the picture) and connect all cathodes of a layer and anodes of a column.

Then we turn on one layer and by turning on the columns to make the required LEDs glow in that layer and then move to the next layer and so on.

This happens so fast that our eyes don’t see the layers turning on and off. So we see an image on the cube. You can see this video from Great Scott to learn more about multiplexing.

https://www.youtube.com/watch?v=uQMUPhyoXoE

Step 6: Why 3x3x3?

You might be thinking why I am making a 3x3x3 LED and why not any other size, the main reason for this is that 3x3x3 is the largest possible size of cube you can make if you want to add Bluetooth to it without making the project more complex by using Shift Registers (https://www.allaboutcircuits.com/textbook/digital/chpt-12/introduction-to-shift-registers/) as Arduino UNO/Nano/pro mini/ has 14 digital + 6 analog = 20 IO pins and a 3x3x3 LED cube requires 9 columns + 3 layers = 12 IO pins and we need two more for the HC 05 Bluetooth module (Tx and Rx) totaling to 14 IO pins.

The 3x3x3 LED cube also has some advantages compared to other sizes –

· For this cube you need not worry about power consumption or dissipation.

· Low Power supply demand.

· We don’t need any switching electronics like transistors for this cube.

· We need lesser logic terminals so we don’t need shift registers or anything like that.

· More pins are available for additional components.

Step 7: LEDs!

LEDs are basically diodes which emit light when its forward voltage is applied and that’s why they are called LEDs (Light Emitting Diodes :), so when we apply positive voltage at its anode (+) and negative voltage at its cathode (-) it lights up.

LEDs come in a variety of shapes, sizes and colours. For this project you can choose any colour of your choice or make different layers with different colours (I haven’t tried it yet but you can :D)

A 5mm or 3mm (diameter) LED would work fine as a bigger one will make it difficult to see the whole cube and the LEDs inside.

Those square LEDs would look nice, but you will face some problems while making a jig with square holes. Instead it’s easy to just drill with a 5mm or 3mm drill bit for round LEDs.

I strongly recommend a diffused (cloudy) LED rather than a clear one as a diffused LED spreads light evenly and the clear one throws almost all light at top, but both work fine.

This project technically needs only 27 LEDs but I have got 30 of them just for mistakes :D. So I have used 30 clear 5mm green LED.

Step 8: Check All the LEDs

Now check all the LEDs with a 5v power supply and a resistor (100 ohms) to be sure that they all light up at the same brightness and there is no faulty piece as you probably wouldn’t want to replace a LED after you have made the whole cube.

It is totally worth spending some time checking the LEDs as I found some faulty ones and removed them earlier.

You can also use those 3v button cells (CR032) as a power source.

Step 9: Sand the LEDs

If you are lazy or have diffused (or cloudy) LEDs then you can ignore this sanding process. Sand all the 27 LEDs with a sandpaper (we used a 150 grit sandpaper) from top and sides to spread the light evenly. Since I didn’t had diffused LEDs, I sanded all the LEDs to give them this diffused effect so they can spread light more evenly.

You can see the difference in the brightness of the clear and diffused LEDs.

Be careful don’t sand the LED too much or it will change its shape to a conical LED.

Step 10: Decide the Size of Your Cube

This is the spacing you want between your LEDs. I made my cube in such a way that there is a gap of 1 inch between 2 LEDs (see the picture).

The gap between 2 layers is as important as the gap between 2 LEDs of the same layer. Equal gaps make the cube look like a cube rather than a cuboid, the distance between 2 LEDs of x axis and y axis should be same as this makes the cube symmetrical.

While deciding the spacing you should keep in mind the size of the LED’s pins, making the gap too wide and the pins of the LEDs won’t reach other LED’s pins and you will have to use connecting wires in between.

So I decided to make the cube with 1 inch spacing.

Step 11: Make a Jig

Soldering all the LEDs in mid-air would make the LED cube in a weird shape, so you need to make a jig where you can solder the LEDs on it to create a layer.

I had this (see in the picture) jig which was made for a 4x4x4 LED Cube laying around, so I utilized it for this project. This jig was made from a piece of plywood I had in my home.

Make a 3x3 grid with 1 inch spacing (see in the picture) and mark the points where we need to drill the holes and then make a small dent on the point so that the drill doesn’t slip and then you can drill holes on the points we just marked with a 5mm drill bit (use 3mm bit if you have 3mm LEDS).

It isn’t mandatory to drill holes on a piece of wood, you can mark holes on a cardboard and punch them use sun board instead of wood or use something else.

Step 12: Bend the Pins of the LEDs

This step will help you solder the common anodes (+) of LEDs in a column. You have to bend the anode pin (longer pin) of the LED away from the cathode pin at a right angle (see the picture).

Now again bend the pin straight in the opposite direction leaving a 1mm gap approximately making it parallel to the other pin, like a Z-bend (see in the picture).

This will shift the anode pin of the LED towards the outer edge making it easy to solder the layers together.

Now repeat this for all the 27 LEDs.

Step 13: Soldering Tips

You need to be careful while soldering as you will need to solder very close to the LEDs as if you heat a LED too much then it may get damage.

These are the basic thing you need for soldering-

· Soldering iron or even better a soldering station (I used a bevel tip)

· Soldering sponge or you could use a steel wool like me to clean your iron, it’s very cheap.

· Solder (I recommend getting a flux core solder)

· Isopropyl alcohol (or just get some sprit from a medical store, it contains isopropyl alcohol)

· Helping hands (it is a nice tool for holding electronic components as they get really hot while soldering)

Make sure your soldering iron is clean. I recommend getting a flux core solder as it makes soldering easy.

Firstly tin the tip of your soldering iron, and then apply some flux where you want to solder, then just touch the part you want to solder with the side of your iron then just put a little solder.

Now clean the area where you just soldered with isopropyl alcohol and also the tip of your soldering iron.

Step 14: Place the LEDs on the Jig and Bend the Negative Pins

Now we need to make a layer, but before that we need to place our LEDs such that we can bend their negative pins easily and then solder them.

Refer the image and place the LEDs in the same orientation as the image and then bend their cathodes to connect LEDs with each other.

The pins of the LEDs should overlap a little.

Step 15: Make the Layer

Now you need to solder the negative pin which we had bend earlier. Tin the end of the LED’s pin and then solder them as usual.

Solder each joint one buy one until you connect all the negative pins together and form a layer.

If the end of your LED is overlapping a lot then you can cut it with a wire cutter or if it is too short then you can use some sort of extending wire to make the joint.

Step 16: Test the Layer and Remove It

Check all the LEDs of the layer as one might have been damaged due to overheating otherwise you will need to desolder a LED after you have made the whole cube.

You can use a 5v power supply with a 100ohms resistor and connect ground to the common cathode of the layer and then connect the VCC of the power supply to the positive pin of a LED via the 100ohms resistor to check the LEDs (refer the image for the diagram). Then connect the VCC via the resistor to one of the anode and if that LED lights up then you are good to go and then check the next LED, and if it doesn’t then may be the LED is damaged due to overheating or the soldering joint isn’t proper.

If your layer passes this step then you can remove the layer from the jig. Slowly start removing it buy pulling out each LED a bit and when all LEDs loosen you can pull it out.

Now your first layer is complete and now you can repeat the steps above 2 more times and make 3 layers in total.

Step 17: Join the Layers

This is the critical part of your cube as you want your cube to be as symmetrical as possible.

Make sure that all your pins are straight and perpendicular and then with your soldering iron tin all the ends as tinning really helps in making a very nice solder joint. Now lay one layer on your work place on its side and then the other layer and bring it close to the other and then solder one corner first then move on to the adjacent corner and solder it. Continue and solder all the corners first.

After that you can start soldering the middle LEDs and then at last the center LED and you’re done joining two layers.

Make sure you solder them at the same orientation that is they should look like this (see the image) from top.

Check the LEDs like you checked the layer in the above step. Now solder the third layer in the same way.

Step 18: Choose a Container

You will have to search for a plastic box or you could get project box which are available in the market. You have to keep in mind the following points while selecting a container.

  • It should be bigger than the LED cube
  • It should have enough space to hide our Arduino UNO and its shield and the 9v battery and other stuff
  • It should not be too large

Step 19: Modify the Box

The container that I choose was transparent so the electronics could be easily seen, so I decided to cover it with some foam paper.

I had many choices of colours but ended up choosing red colour. I cut the paper into strips and pieces that would when attached to the box would cover it and then attached them to the box. You can decorate it in any way you like and in any colour.

You need to modify the box, so that you can fix the cube on top and then hide the electronics inside it.

Start by placing the cube on top of the box and position it as you like, then mark the points where the legs of the LEDs touch the box with a marker. Make small holes where you just marked about 1mm in diameter.

You also need to make 3 additional holes between the central column and the column to which the central column is attached to (see the image).

Step 20: Attach the Cube to the Box

You need to put the cube’s column’s leads through the holes we made earlier. Pull the cube’s leads from inside of the box and adjust the cube till it fits nicely on top of the cube. Then bend the leads from inside of the box in any direction so as to prevent the cube from separating with the box.

We will use the box as the base so make sure that the cube is aligned properly to the box.

Step 21: Make Connections for the Layers

You need to make connections for the layers that is you need to connect the common ground of the layers and bring it to the box. So we need to use some sort of extension to bring the common ground inside the box to connect it.

For this we will be using the holes we made earlier. You need very thin wire so that it isn’t noticeable to anyone as it connects the layer to the box. I had a solid core wire laying around so I removed its plastic insulating coating with a bit of force and was left with a thin bare copper wire.

You need to cut this wire into 3 pieces according to the height of the 3 layers plus 3-4 cm extra. Then tin its one end with the soldering iron and do this for all the pieces.

Insert the wires with the tinned side in front through the 3 holes we made earlier between the central column and the column to which the central column is attached to. First bring the tallest wire through the hole near the center and then bend it and wrap it around the leg of the central LED and then apply some flux and solder it and then clean it with isopropyl alcohol. And you have completed joining the top layer.

Similarly do the same for the second layer through the middle hole and the third layer through the last hole.

Step 22: Connect the Wires to the Cube

Now we need to connect wires to the cube and the Arduino shield (which we will build later).

I prefer using ribbon cable for this job and keeps things organized.

At the time of making the cube I was not sure about which code I will put in the cube so I made the wiring in such a way that I could easily change the pin configuration on the Arduino. I divided the columns into 3 parts front row, middle row and last row so I have 3 ribbon cables with 3 wires in each connecting the cube’s columns inside the box.

You don’t need to do such thing, you can simply use 1 ribbon cable with 9 wires to connect the columns and 1 more ribbon with 3 wires for the layers.

Firstly separate each wire of the ribbon cable and remove the insulation off then tin the ends of the wire. Now you have to solder it to the each of the column (see the picture).

I attached 0.1" female header connectors to the ends of the cable for later connecting it to the controlling circuit and then insulated it with hot glue but it is better to use heat shrink tubing.

Cross check that you have connected the cables in the same orientation as the image.

Now you have completed the cube’s construction and the base for it! And you can set it aside and focus on building the Arduino shield next!

Step 23: What Is Arduino?

The heart of this project is an Arduino UNO board. So it is important to know about it before you use it in this project.

Arduino is an open-source electronics development board. They are called as Arduino boards which have a main computing chip which is a microcontroller. Arduino provides a huge platform for making your projects. You can refer to the original Arduino website to know more about Arduino -

https://www.arduino.cc/

You may find many Arduino boards available in the market and ask which one is suitable for this project. Well I will be using the Arduino UNO board as mentioned earlier.

Arduino UNO is based on the ATmega328p chip, an AVR microcontroller chip. Similarly Arduino Nano and pro mini is also based on the same chip and have same properties except that these have 2 extra exclusive analog input pins which cannot be used for any other purpose. So you can use them for this project since they have the same computing power. UNO has 14 digital pins of which 6 are PWM capable and 6 analog input IO pins. You can know more about Arduino or the ATmega328p by referring its datasheet.

http://pdf1.alldatasheet.com/datasheet-pdf/view/241077/ATMEL/ATMEGA328P.html

Use of Arduino Mega or other boards with high computing power for this project would be an overkill but its upto you if you want then you can still use them.

We will use total 14 pins of Arduino that is pin D2 to D10 for columns and A0 to A2 for the layers and D11 and D12 for Bluetooth communication.

Step 24: Make a Shield for the Arduino

I wanted to use the same Arduino UNO for other projects also so I decided to make a shield for the UNO on which I will keep my Bluetooth module and other parts so that I can easily remove the UNO and use it for other projects.

Cut the perf board

Get your perf board with copper dots and cut a piece with length of 20 dots and width of 19 dots (see the image) we are going to mount our resistors and stuff here.

Modify the headers

Then cut the male headers into 4 parts with each part consisting of- 6 pins for the analog input pins, 8 pins for the power pins, 8 pins for D0 to D7 and 10 pins for D8 to end. As I am an expert in cutting header pins I broke the two 8 pin headers and made them 7 pin headers (see the picture), so I decided that I will solder the 7 pin headers in place and then solder the remaining one header near it and make it work somehow.

You will notice that there is an offset between the D7 and D8 pins of the UNO and this gap is of 160 mil (0.16"), not an even multiple of the 100 mil spacing of the other pins, so it gets difficult to use perf board and header pins. Therefore we need to modify the male headers to fit them.

Place all header pins in their places and then bend the short side of the headers away from the D7 pin (see the picture). Put the perf board on the headers and adjust the headers until you can fit them in the perf board (see the picture). Refer the image, there should be gap of 1 dot on the perf board.

Solder the headers

Now you can remove the headers then apply some flux and then tin them. I used a pair of scissor to hold the headers while tinning them but it’s recommended to use helping hands.

Then place them on the UNO as before and place the perf board on top with its copper side facing downwards and fit the tinned headers and apply some flux and then solder them. It is easy when the headers are already on the UNO and it will match properly.

Clean the extra soldering material like flux with isopropyl alcohol.

Step 25: Make the Connections for Columns

Remember the connectors we used for the ribbon cables to connect our cube and Arduino.

We are going to connect those cables via the male headers on our shield for Arduino. Since I had divided the ribbon wire for columns into 3 parts, I will have to use three 3 pin male headers for columns.

I had less place in my box so I had to use those right angled male pin headers and as they were not available, I had to bend the normal pin headers to make them angled ones. You can choose whichever header you prefer.

Pre-tin the male headers then solder them on the shield by following the images (you can remove the gaps between the male headers if you are using one 9 wire ribbon cable for the columns). While doing this I also soldered 3 more header in advance for the cable for the layers.

Then join them to their following digital pins of the headers connecting the Arduino (refer the images). As you can see in the pictures I used direct solder traces for some joints and wires for the others, both do the job fine it’s on you what you want to use.

Step 26: Make the Connections for Layers

According to our schematics we need to connect our common cathodes to the pins A0, A1, A2. We also need to add some current limiting resistors in between.

I used 33 ohms resistors at first but then later realized that the LEDs were too dim so I ended up using 15 ohms resistors.

As I had soldered the 3 male headers in advance. Bend the pins of the resistors so that it can fit in the PCB with a gap of 4 holes then tin them and solder them. After that connect them to the male headers and connect to the headers joining the Arduino shield ie. pins A0, A1, A2. Refer to the images.

Step 27: What Is HC 05?

HC-05 module is an easy to use Bluetooth SPP (Serial Port Protocol) module, designed for transparent wireless serial connection setup. It uses Bluetooth2.0. You can communicate with a smartphone via Bluetooth and hence can control your Arduino with the smartphone.

For using it with Arduino you should get the one on a breakout board. The module has 6 pins EN (enable), VCC or 5v, GND (ground), TX (transmit), RX (receive) and State pin. We will mainly use the 5v, GND, TX, RX pins of the module. It requires 3.3v power and uses 3.3v logic levels. The breakout board has a voltage regulator at the VCC pin which converts 5v of Arduino to 3.3v for the HC 05, but the other pins aren’t 5v tolerant.

So you can connect the 5v and GND of Arduino directly. You have to connect the TX of the module to the RX of the Arduino and RX of the module to the TX of the Arduino. As the other pins aren’t 5v tolerant we can connect the TX of the module to the RX of the Arduino directly as Arduino is compatible but while making the other connection we cannot directly connect TX of the Arduino to the RX of the module as the 5v signal can destroy the module.

Therefore we have to use a voltage divider in between which will reduce the voltage to 3.3v. We will connect it like this-(see the image) I used a 2.2k resistor and a 4.7k resistor.

You could get one from Amazon or e-bay.

In India

https://www.amazon.in/Bluetooth-Transceiver-Module-TTL-Outputs-HC05/dp/B00R95Y0AK/

https://www.ebay.in/itm/HC-05-Wireless-Bluetooth-RF-Transceiver-Module-Serial-RS232-TTL-for-Arduino/172770299345/

International

https://www.amazon.com/HiLetgo-Wireless-Bluetooth-Transceiver-Arduino/dp/B071YJG8DR/

https://www.ebay.com/itm/HC-05-6-Pin-Wireless-Bluetooth-RF-Transceiver-Module-Serial-RS232-For-Arduino/232412681033

Step 28: Check the HC-05

If you have doubt whether your HC-05 is working properly then you can perform this test to make sure everything is good.

For this test you need-

  • bread board
  • 5v power supply
  • HC-05 (of course)
  • jumper wires

Connect the 5v and GND of the HC-05 to the 5v and GND of power supply then short the TX and RX pins of the HC-05 (connect TX to RX).

Now download an app called S2Terminal in your smartphone from playstore and connect to the HC-05 via bluetooth. It will ask for a pin code which is mostly 0000 or 1234.

Now type any random alphabets on the app and click the send button. If you see what you typed in red letters and then the same repeated in blue letters then your module is working properly.

The module receives the signal from the app and throw it through the TX pin but we have shorted the two pins so the signal travels and reaches the RX pin and the module then transmits the signal back to the app so we see the letters repeat and can conclude that the module is fine.

Step 29: Add HC-05 to the Shield

As mentioned earlier we are going to connect the module in the same way expect that instead of using the D0 and D1 pin of the Arduino we will use the pins D10 and D11 as RX and TX respectively.

I am going to place my Bluetooth module underneath the shield as I have less space on top so my photos could confuse you so keep that in mind.

I want my Bluetooth to be detachable so that I can use it for future projects so I will use headers. My Bluetooth module has angled male headers so I should use angled female headers which I don’t have so I will bend the pins of normal female headers (see the picture).

On the shield start by soldering the header in place first then the resistors and at last solder the wires and make all the connections. Make sure you follow the schematics. You can also check all joints with the continuity function with a multi meter.

You have now successfully completed making shield for Arduino.

Step 30: Connect Controller to the LED Cube

Now that you have completed making the cube and the controller it’s time to connect both of them together. You have to connect the female headers of the cube to the male headers of the controller.

Connect them so that-

Top layer è A2

Middle layer è A1

Bottom layer è A0

Now connect the columns according to images. Cross check that you have connected them properly.

Step 31: Power

To power the Arduino I will use a 9v battery for power.

Arduino has a vin pin which has a 5v voltage regulator and it is connected to the DC jack.

Connect the battery connector to the DC jack with a switch in between (see the image). Now hot glue them together.

Step 32: Install Arduino IDE

Now you need to install the latest version of Arduino IDE. Arduino IDE is the programming software for Arduino.

https://www.arduino.cc/en/Guide/HomePage

Go to the above link and under the “Install the Arduino Desktop IDE” section click the type of your OS in your PC/Laptop. Then follow the instructions and download the IDE.

Step 33: Install Remote XY Library and App

We are going to use the RemoteXY which is a mobile graphical user interface for Arduino boards and other controllers. To know more about it visit its official site- http://remotexy.com/

In order to use the RemoteXY in our sketch (program) we first need to install the RemoteXY library.

http://remotexy.com/en/help/how-install-library/

This link will guide you for installation of the RemoteXY library.

Now we have to download the app in our smartphone. It is available on play store, you can install it from there. There are 2 versions available free one and paid one, install the free one.

Step 34: Test the LED Cube

You have the whole cube with all the software ready its time to test the cube.

I have written a code to test wiring of the cube to check if all the LEDs work and if they are wired correctly. It will begin by lighting all LEDs for 2s then lights each LED one after the other starting from left bottom front LED to right top back LED.

See the video to check whether it does the same.

If it does something weird then try flipping the connectors on the shield.

For those who cannot download the file or have error in downloading it, I have have the code written below so you can just copy paste it. :)

int columns[] = {2,3,4,5,6,7,8,9,10}; //initializing all column pins
int layers[] = {A0,A1,A2}; //initializing all layer pins void setup() { for(int i = 0; i < (sizeof(columns)/sizeof(int)); i++) { pinMode(columns[i],OUTPUT); // initializing all column pins as ouput } for (int i = 0; i < (sizeof(layers)/sizeof(int)); i++) { pinMode(layers[i],OUTPUT); // initializing all layer pins as ouput } TurnAllOff(); // turning all LEDs off } void loop() {

TurnAllOn(); //Lights whole Cube delay(2000); //waits for 2s OneByOne(); //Lights each LED individually one after the other

}

void TurnAllOn (){ for (int i = 0; i < (sizeof(layers)/sizeof(int)); i++) { digitalWrite(layers[i],LOW); // pulling all layers low } for (int i = 0; i < (sizeof(columns)/sizeof(int)); i++) { digitalWrite(columns[i],HIGH); // pulling all columns high } }

void TurnAllOff (){ for (int i = 0; i < (sizeof(columns)/sizeof(int)); i++) { digitalWrite(columns[i],LOW); for (int i = 0; i < (sizeof(layers)/sizeof(int)); i++) { digitalWrite(layers[i],HIGH); } } }

void OneByOne (){ int delayTime =1000; TurnAllOff(); for (int i = 0; i < (sizeof(layers)/sizeof(int)); i++) { digitalWrite(layers[i],LOW); // pulling a layer low for (int i = 0; i < (sizeof(columns)/sizeof(int)); i++) { digitalWrite(columns[i],HIGH); delay(delayTime);// pulling all columns high digitalWrite(columns[i],LOW); } digitalWrite(layers[i],HIGH); // pulling a layer high } TurnAllOff(); }

Step 35: Final Code- Add RemoteXY Source Code

To be able to control our cube using the RemoteXY app we need to add some lines of code in the beginning.

To use the app I created go to this link-

http://remotexy.com/en/editor/b467b12e438413959cc5815555e36a90/

Now click the “Get the source code” button then some code will appear copy the code and paste it in the Arduino IDE the code initializes all the things we need above the void setup.

In the void setup there is a line “RemoteXY_Init ();” this line initializes all the variables and other stuff needed for the RemoteXY app to function.

Similarly in void loop there is a line “RemoteXY_Handler ();” this line is very important.

This is what the code means-

http://remotexy.com/en/help/whatiscode/

Step 36: Final Code- Initialize the IO Pins

We first create 2 variables called columns and layers where we store the name of the IO pins in an array for columns and layers.

In the void setup we first initialize everything required for the RemoteXY app then we set up a for loop in which we call each pin of the columns variable and set it as an output pin and do the same for layers.

We then call a function called ‘TurnAllOff ();’ which turns all LEDs off to avoid turning on of unnecessary LEDs in the beginning of the program.

Step 37: Final Code- TurnAllOff

This function switches off all the LEDs.

There are 2 for loops here one calls each pin of the layers and pulls it high and then the other calls each pin of the columns and pulls it low.

Remember that we have connected common cathodes of the LEDs as layers and common anodes of the LEDs as columns.

So pin of layers are active low and pins of columns are active high. Therefore pulling them opposite switches all LEDs off.

Step 38: Final Code- TurnAllOn

This function switches on all the LEDs.

There are 2 for loops one inside the other, the outer loop calls each pin of the layers and pulls it low.

Then the inner loop calls each pin of the columns and pulls it high and this causes the LEDs to light up.

Then outer loop continues and pulls that layer high.

The loop then does this for the next layer it seems that all LEDs are kept on.

Step 39: Final Code- OneByOne

This turns on each LED one after the other starting from left bottom front LED to right top back LED. It is the one I have used in the test code.

I created a variable called delayTime which stores the amount of time in which the next LED will light up.

This is same as the TurnAllOn function the difference is that there is a delaywhich waits for the number of milliseconds that is stored in the delayTime variable and then turns pulls that column low again and repeats.

See the video to see this pattern.

Step 40: Final Code- CircleAround

In this pattern the 2 columns of LEDs will revolve around the center, the central column could be kept on or off according to the programmer (this was nicer than I expected).

We first put a Boolean argument ‘showMid’ which lights central column if it is and turns it off if it is 0.

I created a variable ‘midColumn’ where the pin of the central column is stored. I then created 2 more variables where the pins of the outer columns is stored and in the other the delay is stored.

We pull all layers low then if the showMid condition is true we pull up the middle pin.

Then turn on 2 opposite columns and spin them in clockwise direction.

See the video to understand the pattern.

Step 41: Final Code- LayerByLayerUp

Layers are turned on one after the other from bottom to top. Same as TurnAllOn but delay between turning on and off of the layers.

I created a variable called delayTime which stores the amount of time. This delay time comes in between turning on and off of the layers.

See the video to understand the pattern.

Step 42: Final Code- LayerByLayerDown

Layers are turned on one after the other from bottom to top. Same as LayerByLayerUp but in opposite direction.

I created a variable called delayTime which stores the amount of time. This delay time comes in between turning on and off of the layers.

See the video to understand the pattern.

Step 43: Final Code- LayerUpAndDown

This pattern looks like layers moving up and down.

LayerByLayerUp and LayerByLayerDown pattern are mixed. First the LayerByLayerUp function is called then the LayerUpAndDown function is called.

See the video to understand the pattern.

Step 44: Final Code-Edges

The edges of the cube are displayed in this pattern.

We first put an argument called ‘amount’ that decides how many times to repeat the pattern.

The first for loop repeats all that’s inside it for the number of times stored in ‘amount’.

We first pull one layer low then if it is the middle layer then we only turn on the corner columns otherwise all the column expect the middle most column.

The layer we turned on is turned off (ie. pulled high). And the loop continues.

See the video to understand the pattern.

Step 45: Final Code- Centre

This turns on the centre LED.

The ‘TurnAllOff’ function is called to turn all LEDs off.

The middle layer is pulled low and the central column is pulled high.

See the video to understand the pattern.

Step 46: Final Code- InAndOut

This mixes up the centre and edges pattern to create Boom-Boom effect!

The edges pattern is kept on for 1000 times roughly equaling to 200 milliseconds and then the centre pattern is displayed for 200 milliseconds.

See the video to understand the pattern.

Step 47: Final Code-Void Loop

Void Loop is the most interesting part of the program, this is what your Arduino is going to run.

At first there is the RemoteXY_Handler which looks after the things for RemoteXY.

Then there is a switch case section which checks which button on the app is selected and displays a pattern accordingly.

The void loop repeats itself infinitely.

And now you have finished making a 3x3x3 LED Cube with Bluetooth!

Step 48: Upload the Code

What’s the use if you make an awesome Arduino project and don’t upload the code, well then you can’t see it running the code so upload it.

Download the final code and upload it to your Arduino. Plug the Arduino to your PC and then in the tools section make sure you have selected the correct board type and port. Now hit the upload button and you will see the TX and RX LEDs blinking fast and you have successfully uploaded the code.

For those who cannot download the file or have error in downloading it, I have have the code written below so you can just copy paste it. :)

/*
-- 3x3x3 LED cube control by Akash Thakur -- This source code of graphical user interface has been generated automatically by RemoteXY editor. To compile this code using RemoteXY library 2.3.3 or later version download by link http://remotexy.com/en/library/ To connect using RemoteXY mobile app by link http://remotexy.com/en/download/ - for ANDROID 4.1.1 or later version; - for iOS 1.2.1 or later version; This source code is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. */

////////////////////////////////////////////// // RemoteXY include library // //////////////////////////////////////////////

// RemoteXY select connection mode and include library #define REMOTEXY_MODE__SOFTSERIAL #include <SoftwareSerial.h>

#include <RemoteXY.h>

// RemoteXY connection settings #define REMOTEXY_SERIAL_RX 11 #define REMOTEXY_SERIAL_TX 12 #define REMOTEXY_SERIAL_SPEED 9600

// RemoteXY configurate #pragma pack(push, 1) uint8_t RemoteXY_CONF[] = { 255,1,0,0,0,11,0,8,13,0, 3,138,8,22,81,9,2,26 }; // this structure defines all the variables of your control interface struct {

// input variable uint8_t select_1; // =0 if select position A, =1 if position B, =2 if position C, ...

// other variable uint8_t connect_flag; // =1 if wire connected, else =0

} RemoteXY; #pragma pack(pop)

///////////////////////////////////////////// // END RemoteXY include // /////////////////////////////////////////////

int columns[] = {2,3,4,5,6,7,8,9,10}; //declaring all column pins int layers[] = {A0,A1,A2}; //declaring all layer pins

void setup() { RemoteXY_Init (); for(int i = 0; i < (sizeof(columns)/sizeof(int)); i++) { pinMode(columns[i],OUTPUT); // setting all column pins to ouput } for (int i = 0; i < (sizeof(layers)/sizeof(int)); i++) { pinMode(layers[i],OUTPUT); // setting all layer pins to ouput } TurnAllOff (); // turning all LEDs off }

void TurnAllOff (){ for (int i = 0; i < (sizeof(columns)/sizeof(int)); i++) { digitalWrite(columns[i],LOW); } for (int i = 0; i < (sizeof(layers)/sizeof(int)); i++) { digitalWrite(layers[i],HIGH); } }

void TurnAllOn (){ for (int i = 0; i < (sizeof(layers)/sizeof(int)); i++) { digitalWrite(layers[i],LOW); // pulling all layers low for (int i = 0; i < (sizeof(columns)/sizeof(int)); i++) { digitalWrite(columns[i],HIGH); // pulling all columns high } digitalWrite(layers[i],HIGH); // pulling all layers low } }

void OneByOne (){ int delayTime =80; TurnAllOff (); for (int i = 0; i < (sizeof(layers)/sizeof(int)); i++) { digitalWrite(layers[i],LOW); // pulling a layer low for (int i = 0; i < (sizeof(columns)/sizeof(int)); i++) { digitalWrite(columns[i],HIGH); delay(delayTime);// pulling all columns high digitalWrite(columns[i],LOW); } digitalWrite(layers[i],HIGH); // pulling a layer high }

}

void CircleAround(bool showMid) { int midColumn = columns[4]; // pin of middle column is declared int outerColumns[8] = {columns[0], columns[1], columns[2], columns[5], columns[8], columns[7], columns[6], columns[3]}; //pins of outer columns are declared int delayTime = 100;

// for(int i = 0; i < amount; i++) { for (int i = 0; i < (sizeof(layers)/sizeof(int)); i++) { digitalWrite(layers[i], LOW); } if(showMid) digitalWrite(midColumn, HIGH); // Outer LEDs: for(int i = 0; i < (sizeof(outerColumns)/sizeof(int)); i++) { int y; if(i >= 4){ y = i-4; //to light opposite column also } else{ y = i+4; } digitalWrite(outerColumns[i], HIGH); digitalWrite(outerColumns[y], HIGH); delay(delayTime); digitalWrite(outerColumns[i], LOW); digitalWrite(outerColumns[y], LOW); } // } }

void LayerByLayerUp() { int delayTime = 100; // for (int i = 0; i < amount; i++){ for (int i = 0; i < (sizeof(layers)/sizeof(int)); i++) { digitalWrite(layers[i],LOW); // a layer is grounded for (int i = 0; i < (sizeof(columns)/sizeof(int)); i++) { digitalWrite(columns[i],HIGH); // turn ON all columns in layer } delay(delayTime); for (int i = 0; i < (sizeof(columns)/sizeof(int)); i++) { digitalWrite(columns[i],LOW); // turn OFF all columns in layer } digitalWrite(layers[i],HIGH); // layer is pulled up } // } }

void LayerByLayerDown() { int delayTime = 100; for (int i = (sizeof(layers)/sizeof(int)); i >= 0; i--) { digitalWrite(layers[i],LOW); // a layer is grounded for (int i = 0; i < (sizeof(columns)/sizeof(int)); i++) { digitalWrite(columns[i],HIGH); // turn ON all columns in layer } delay(delayTime); for (int i = 0; i < (sizeof(columns)/sizeof(int)); i++) { digitalWrite(columns[i],LOW); // turn OFF all columns in layer } digitalWrite(layers[i],HIGH); // layer is pulled up } // } }

void LayerUpAndDown() { //to mix both patternsern LayerByLayerUp(); LayerByLayerDown(); }

void Edges(int amount){ for (int i = 0; i < amount; i++){ for (int i = 0; i < (sizeof(layers)/sizeof(int)); i++) { digitalWrite(layers[i],LOW); if (i == 1){ digitalWrite(columns[0],HIGH); digitalWrite(columns[1],LOW); digitalWrite(columns[2],HIGH); digitalWrite(columns[3],LOW); digitalWrite(columns[4],LOW); digitalWrite(columns[5],LOW); digitalWrite(columns[6],HIGH); digitalWrite(columns[7],LOW); digitalWrite(columns[8],HIGH);

} else{ for (int i = 0; i < (sizeof(columns)/sizeof(int)); i++) { if (i == 4){ digitalWrite(columns[i],LOW); } else{ digitalWrite(columns[i],HIGH); } } } for (int i = 0; i < (sizeof(columns)/sizeof(int)); i++) { digitalWrite(columns[i],LOW); } digitalWrite(layers[i],HIGH); } } }

void Centre(){ TurnAllOff(); digitalWrite(layers[1],LOW); digitalWrite(columns[4],HIGH); }

void InAndOut(){ // for (int i = 0; i < amount; i++){ Edges(1000); Centre(); delay(200); // } } void loop() { RemoteXY_Handler ();

switch (RemoteXY.select_1){ case 0: // current position A TurnAllOff (); break; case 1: // current position B TurnAllOn (); break; case 2: // current position C OneByOne (); break; case 3: // current position D CircleAround (1); break; case 4: // current position E LayerByLayerUp (); break; case 5: // current position F LayerByLayerDown (); break; case 6: // current position G LayerUpAndDown (); break; case 7: // current position H Edges (1); break; case 8: // current position I Centre (); break; case 9: // current position J InAndOut (); break; default: TurnAllOff (); break; } }

Step 49: Use the RemoteXY App

Open the app in your smartphone and click the plus icon then to the Bluetooth and select the HC-05 option. It will ask for a pin try 0000 or 1234.
Then the app will open the window which you had created. Select the pattern you want to see!

Step 50: No Bluetooth? No Problem

If you want to make you cube without the control from Bluetooth then don’t worry you have to just change some things.

  • no need to download the RemoteXY library and app
  • no need to use/buy bluetooth module
  • no need to make additional modifications on the Arduino shield

I have already made a program without Bluetooth. Ready to upload!

Download it from below!

For those who cannot download the file or have error in downloading it, I have have the code written below so you can just copy paste it. :)

int columns[] = {2,3,4,5,6,7,8,9,10}; //declaring all column pins
int layers[] = {A0,A1,A2}; //declaring all layer pins void setup() { for(int i = 0; i < (sizeof(columns)/sizeof(int)); i++) { pinMode(columns[i],OUTPUT); // setting all column pins to ouput } for (int i = 0; i < (sizeof(layers)/sizeof(int)); i++) { pinMode(layers[i],OUTPUT); // setting all layer pins to ouput } TurnAllOff(); Serial.begin(9600); // turning all LEDs off } void loop() {

TurnAllOn(); delay(2000); TurnAllOff(); CircleAround(5,1); LayerByLayerUp(3); OneByOne(); LayerByLayerDown(3); LayerUpAndDown(3); InAndOut(5); Edges(1000); }

void TurnAllOn (){ for (int i = 0; i < (sizeof(layers)/sizeof(int)); i++) { digitalWrite(layers[i],LOW); // pulling all layers low } for (int i = 0; i < (sizeof(columns)/sizeof(int)); i++) { digitalWrite(columns[i],HIGH); // pulling all columns high } }

void TurnAllOff (){ for (int i = 0; i < (sizeof(columns)/sizeof(int)); i++) { digitalWrite(columns[i],LOW); } for (int i = 0; i < (sizeof(layers)/sizeof(int)); i++) { digitalWrite(layers[i],HIGH); } }

void OneByOne (){ int delayTime =100; TurnAllOff(); for (int i = 0; i < (sizeof(layers)/sizeof(int)); i++) { digitalWrite(layers[i],LOW); // pulling a layer low for (int i = 0; i < (sizeof(columns)/sizeof(int)); i++) { digitalWrite(columns[i],HIGH); delay(delayTime);// pulling all columns high digitalWrite(columns[i],LOW); } digitalWrite(layers[i],HIGH); // pulling a layer high }

}

void CircleAround(int amount, bool showMid){ // amount = no. of times to repeat the pattern int midColumn = columns[4]; // pin of middle column is declared int outerColumns[8] = {columns[0], columns[1], columns[2], columns[5], columns[8], columns[7], columns[6], columns[3]}; //pins of outer columns are declared int delayTime = 100; TurnAllOff(); for(int i = 0; i < amount; i++) { for (int i = 0; i < (sizeof(layers)/sizeof(int)); i++) { digitalWrite(layers[i], LOW); if(showMid) digitalWrite(midColumn, HIGH); } // Outer LEDs: for(int i = 0; i < (sizeof(outerColumns)/sizeof(int)); i++) { int y; if(i >= 4){ y = i-4; //to light opposite column also } else{ y = i+4; } digitalWrite(outerColumns[i], HIGH); digitalWrite(outerColumns[y], HIGH); delay(delayTime); digitalWrite(outerColumns[i], LOW); digitalWrite(outerColumns[y], LOW); } } TurnAllOff(); }

void LayerByLayerUp(int amount){ // amount = no. of times to repeat the pattern int delayTime = 150; TurnAllOff(); for (int i = 0; i < amount; i++){ for (int i = 0; i < (sizeof(layers)/sizeof(int)); i++) { digitalWrite(layers[i],LOW); // a layer is grounded for (int i = 0; i < (sizeof(columns)/sizeof(int)); i++) { digitalWrite(columns[i],HIGH); // turn ON all columns in layer } delay(delayTime); for (int i = 0; i < (sizeof(columns)/sizeof(int)); i++) { digitalWrite(columns[i],LOW); // turn OFF all columns in layer } digitalWrite(layers[i],HIGH); // layer is pulled up } } }

void LayerByLayerDown(int amount){ int delayTime = 150; TurnAllOff(); for (int i = 0; i < amount; i++){ for (int i = (sizeof(layers)/sizeof(int)); i >= 0; i--) { digitalWrite(layers[i],LOW); // a layer is grounded for (int i = 0; i < (sizeof(columns)/sizeof(int)); i++) { digitalWrite(columns[i],HIGH); // turn ON all columns in layer } delay(delayTime); for (int i = 0; i < (sizeof(columns)/sizeof(int)); i++) { digitalWrite(columns[i],LOW); // turn OFF all columns in layer } digitalWrite(layers[i],HIGH); // layer is pulled up } } }

void LayerUpAndDown(int amount){ //to mix both patterns | amount = no. of times to repeat the pattern for (int i = 0; i < amount; i++){ LayerByLayerUp(1); LayerByLayerDown(1); } } void Edges(int amount){ TurnAllOff(); for (int i = 0; i < amount; i++){ for (int i = 0; i < (sizeof(layers)/sizeof(int)); i++) { digitalWrite(layers[i],LOW); if (i == 1){ digitalWrite(columns[0],HIGH); digitalWrite(columns[1],LOW); digitalWrite(columns[2],HIGH); digitalWrite(columns[3],LOW); digitalWrite(columns[4],LOW); digitalWrite(columns[5],LOW); digitalWrite(columns[6],HIGH); digitalWrite(columns[7],LOW); digitalWrite(columns[8],HIGH);

} else{ for (int i = 0; i < (sizeof(columns)/sizeof(int)); i++) { if (i == 4){ digitalWrite(columns[i],LOW); } else{ digitalWrite(columns[i],HIGH); } } } for (int i = 0; i < (sizeof(columns)/sizeof(int)); i++) { digitalWrite(columns[i],LOW); } digitalWrite(layers[i],HIGH); } } }

void Centre(){ TurnAllOff(); digitalWrite(layers[1],LOW); digitalWrite(columns[4],HIGH); }

void InAndOut(int amount){ for (int i = 0; i < amount; i++){ Edges(1000); Centre(); delay(200); } }

Epilog Challenge 9

Participated in the
Epilog Challenge 9

Arduino Contest 2017

Participated in the
Arduino Contest 2017

Remote Control Contest 2017

Participated in the
Remote Control Contest 2017