Build your own RGB LED Cube Part 3: optimisation and animations

**Hardware Changes**

Firstly, I think the cube is too bright sometimes, and it can get really distracting. Changing the brightness was only possible through reprogramming until now, so I added a 10k potentiometer to set the brightness from 0 to 4095 continuously.

The process was simple as always; I would hope that the shaft and mount of the potentiometer would not have any issues. One side of the potentiometer connects to 5 volts at the switch, and the other side connects directly to ground at the DC check. The middle pin connects to analog pin 4 of the Arduino, and that's it! It was pretty easy to adapt the code; all I needed was another integer which I called "prayut." The analog read function and the map function to convert our 10-bit value of our analog read into a 12-bit value for the TLZ were used.

As you can see, it works really well. Next change I notice that sometimes my cube does not do what I want; it just goes apeshit. The reason was all those precision sockets - yeah, precision my ass! Look at that; I press the I sees a bit and it flashes however it wants there or connectivity problems. So I changed the sockets to normal ones, and yes, it was horrible. But now everything works fine.

These two things were basically all hardware changes. Now let's take a look at the code.

**Code Changes**

I included the second library called Digital I/O Performance because the digital write functions we use to multiplex are actually pretty slow. We could make it faster by using POD commands, but that would make it look kind of complicated and not beginner-friendly. This library actually translates all the digitalWrite functions into the POD commands without changing stuff around.

Here on La Silla scope, we can clearly see the difference which proves the pot comments are around 30 times faster than the digital write functions. Next thing in the old code I used the integers ARVAR C AR and so on to give a brightness value for all 192 LEDs, and this can get really annoying when creating animations.

So I created a class for red, green, and blue values; let's test those with the first test animation. We start with red LED zero which is basically red LED one but erased top of the number zero. Each time the stretch time is reached, the LED value goes one up in reality it looks like this.

**Animations**

With this animation, you can easily see whether you connected your wires correctly to the PCB. Frost red LED is down on the right corner now green well that was unexpected and blue glue the same is red so I just switched the connector for the green LEDs around and green works as well.

Making more complex animations takes more time; here's one I made which consists of two functions - the Red turn on function turns the red LEDs on obviously which are defined in the turn on list. And in the wall function, it is the turn on list of the red LED is defined.

We have 12 studied pictures at the beginning of each if statement we use the reset function which basically turns all red green and blue LEDs off now I define my red LEDs which I want to turn on labeled from 0 to 63. And in the last step, I use my Red turn on function to turn on the lights.

After one if statement, the integer Q which are used here as a counter goes one up and the cube will update and show us the first picture then the second if statement gets active and we see the second picture and so on. And here's the final animation.

**Color Animations**

Let's play around the colors now I made a small color change animation which lights up red green and blue one after the other to full brightness and then slowly dims them until they are talk and I faded the colors into each other which mixes them up a bit really pretty.

The last animation is gonna be really simple but still my favorite. I used the random function of the Arduino to turn on ten random LEDs of red, green, and blue with a brightness value between five hundred and four thousand ninety-five. The shows of the capabilities of such a cube very well and of course you can control the brightness.

Now you can modify my codes to make your own animations feel free to share them on my Facebook page or in the comment section. I hope you like the RGB LED cube project if so like, share, and subscribe stay creative and I will see you next time.

WEBVTTKind: captionsLanguage: enthis is how we left the hoop at the end of part 2 now it is time to optimize it and make some custom animations first of all I think the cube is too bright sometimes it can get really distracting and changing the brightness is only possible through reprogramming it until now so I added a 10k potentiometer to set the brightness from 0 to 4095 continuously the process was simple as always I would hope the shaft and mount of the potentiometer would have not one side of the potentiometer connects to 5 volt at the switch and the other side connects directly to ground at the DC check the middle pin connects to analog pin 4 of the Arduino and that's it it was pretty easy to adapt the code all I needed was another integer which I called prayut the analog read function and the map function to convert our 10 bit value of our analog read into a 12 bit value for the tlz and as you can see it works really well ok next change I notice that sometimes my cube does not do what I want it just goes apeshit the reason all those precision sockets yeah precision my ass look at that I press the I sees a bit and it flashes however it wants there our connectivity problems so I changed the sockets to normal ones and yes it was horrible to the solo and resold all the sockets but now everything works fine these two things were basically all the hardware changes now let's take a look at the code I included the second library called digital i/o performance because the digital write functions we use to multiplex are actually pretty slow we could make it faster by using pod commands but that would make it look kind of complicated and not beginner-friendly this library actually translates all the to write functions into the pod commands without changing stuff around and here on La Silla scope we can clearly see the difference which proves the pot comments are around 30 times faster than the digital write functions next thing in the old code I used the integers AR VAR c AR and so on to give a brightness value for all 192 LEDs and this can get really annoying when creating animations so I created a race for red green and blue values let's test those with the first test animation we start with red LED zero which is basically red LED one but erase top of the number zero and each time the stretch time is reached the LED value goes one up in reality it looks like this with this animation you can easily see whether you connected your wires correctly to the PCB frost red LED is down on the right corner now green well that was unexpected and blue glue the same is red so I just switched the connector for the green LEDs around and green works as well making more complex animations takes more time here's one I made which consists of two functions the red turn on function turns the red LEDs on obviously which are defined and the turn on list and in the wall function is the turn on list of the red LED is defined as you can see we have 12 studied pictures at the beginning of each if statement we use the reset function which basically turns all red green and blue LEDs off now I define my red LEDs which I want to turn on labeled from 0 to 63 and in the last step I use my red turn on function to turn on the lights after one if statement the integer Q which are used here as a counter goes one up and the cube will update and show us the first picture then the second if statement gets active and we see the second picture and so on and here's the final animation let's play around the colors now I made a small color change animation which lights up red green and blue one after the other to full brightness and then slowly Timms them until they are talk and I faded the colors into each other which mixes them up a bit really pretty the last animation is gonna be really simple but still my favorite I used the random function of the Arduino to turn on ten random LEDs of red green and blue with a brightness value between five hundred and four thousand ninety five the shows of the capabilities of such a cube very well and of course you can control the brightness now you can modify my codes to make your own animations feel free to share them on my Facebook page or in the comment section I hope you like the RGB LED cube project if so like share and subscribe stay creative and I will see you next time youthis is how we left the hoop at the end of part 2 now it is time to optimize it and make some custom animations first of all I think the cube is too bright sometimes it can get really distracting and changing the brightness is only possible through reprogramming it until now so I added a 10k potentiometer to set the brightness from 0 to 4095 continuously the process was simple as always I would hope the shaft and mount of the potentiometer would have not one side of the potentiometer connects to 5 volt at the switch and the other side connects directly to ground at the DC check the middle pin connects to analog pin 4 of the Arduino and that's it it was pretty easy to adapt the code all I needed was another integer which I called prayut the analog read function and the map function to convert our 10 bit value of our analog read into a 12 bit value for the tlz and as you can see it works really well ok next change I notice that sometimes my cube does not do what I want it just goes apeshit the reason all those precision sockets yeah precision my ass look at that I press the I sees a bit and it flashes however it wants there our connectivity problems so I changed the sockets to normal ones and yes it was horrible to the solo and resold all the sockets but now everything works fine these two things were basically all the hardware changes now let's take a look at the code I included the second library called digital i/o performance because the digital write functions we use to multiplex are actually pretty slow we could make it faster by using pod commands but that would make it look kind of complicated and not beginner-friendly this library actually translates all the to write functions into the pod commands without changing stuff around and here on La Silla scope we can clearly see the difference which proves the pot comments are around 30 times faster than the digital write functions next thing in the old code I used the integers AR VAR c AR and so on to give a brightness value for all 192 LEDs and this can get really annoying when creating animations so I created a race for red green and blue values let's test those with the first test animation we start with red LED zero which is basically red LED one but erase top of the number zero and each time the stretch time is reached the LED value goes one up in reality it looks like this with this animation you can easily see whether you connected your wires correctly to the PCB frost red LED is down on the right corner now green well that was unexpected and blue glue the same is red so I just switched the connector for the green LEDs around and green works as well making more complex animations takes more time here's one I made which consists of two functions the red turn on function turns the red LEDs on obviously which are defined and the turn on list and in the wall function is the turn on list of the red LED is defined as you can see we have 12 studied pictures at the beginning of each if statement we use the reset function which basically turns all red green and blue LEDs off now I define my red LEDs which I want to turn on labeled from 0 to 63 and in the last step I use my red turn on function to turn on the lights after one if statement the integer Q which are used here as a counter goes one up and the cube will update and show us the first picture then the second if statement gets active and we see the second picture and so on and here's the final animation let's play around the colors now I made a small color change animation which lights up red green and blue one after the other to full brightness and then slowly Timms them until they are talk and I faded the colors into each other which mixes them up a bit really pretty the last animation is gonna be really simple but still my favorite I used the random function of the Arduino to turn on ten random LEDs of red green and blue with a brightness value between five hundred and four thousand ninety five the shows of the capabilities of such a cube very well and of course you can control the brightness now you can modify my codes to make your own animations feel free to share them on my Facebook page or in the comment section I hope you like the RGB LED cube project if so like share and subscribe stay creative and I will see you next time you