charlieplex code 4x4x4 rgb arduino nano code

Good day all,

i'm new to this Arduino IDE. I don't know how to change the animation for my "charlieplex code 4x4x4".

only 1 type of animation after i loaded the code. I did not change any in the code.

This is the one I used.

The only animation in my cube

Your code uses interrupts. Variables that are changed in interrupt service routines (ISR) and are shared with normal 'code' should be declared volatile.

Search your cubeplex.h for ISR(TIMER1_OVF_vect) . You will find

int animationTimer = 0;
int animationMax = 0;

ISR(TIMER1_OVF_vect) {
  if (animationTimer == animationMax) {
    continuePattern = false;

Change the first two lines to

volatile int animationTimer = 0;
volatile int animationMax = 0;

Next find the declaration of continuePattern; the line looks like

bool continuePattern = false;

and change it to

volatile bool continuePattern = false;

Next search your code for ISR(TIMER2_OVF_vect). You will find


In there you will find


  if (count > pwmm){

count is a local variable and the declaration does not need to be changed. pwmm is not local and probably needs to be changed.

Find the line that contains the declaration of pwmm;

int pwmm = 0;

and change it to

volatile int pwmm = 0;

2) There are a few more lines that change variables that are declared outside the ISR. Also find the lines

_frame_light * _cube__frame;
_frame_light * _cube_current_frame;
char * _cube_buffer;

and change them to

volatile _frame_light * _cube__frame;
volatile _frame_light * _cube_current_frame;
volatile char * _cube_buffer;

Give that a shot; if it does not solve it, I do not know.