Page 90 - MDP2022-3
P. 90

제  3  장  소프트웨어  설계  (000)

            1.  개요

             RGB  LED의  특성을  활용하여  4x4x4  LED  CUBE를  16개의  핀으로만  제어할  수  있도록
            software를  구성하여  LED  CUBE를  구성


            2.  소프트웨어

            #include  "cubeplex.h"


            int  color  =  red;


            void  setup()  {
                initCube();
                animationMax  =  600;
            }
            void  loop()  {
                RandomPlanarFlop();
            }


            void  RandomPlanarFlop()  {
                int  side  =  1;
                continuePattern  =  true;
                int  animationSpeed  =  100;
                while  (continuePattern)  {
                    if  (side  ==  1)  {
                        switch(random(0,5))  {
                            case  0:
                                for  (int  y  =  3;  y  >  -1;  y--){
                                    for  (int  z  =  0;  z  <  4;  z++)  drawLine(color,0,3,z,3,y,z);
                                    flushBuffer();
                                    clearBuffer();
                                    delay(animationSpeed);
                                }
                                for  (int  x  =  3;  x  >  -1;  x--)  {
                                    for  (int  z  =  0;  z  <  4;  z++)  drawLine(color,0,3,z,x,0,z);
                                    flushBuffer();
                                    clearBuffer();
                                    delay(animationSpeed);
                                }
                                side  =  2;break;
                            case  1:
                                for  (int  y  =  3;  y  >  -1;  y--)  {
                                    for  (int  z  =  0;  z  <  4;  z++)  drawLine(color,3,3,z,0,y,z);
                                    flushBuffer();
                                    clearBuffer();
   85   86   87   88   89   90   91   92   93   94   95