Led romb

    It was evening, there was nothing. (c)



    It was about 3 years ago. I stumbled upon a single video LED cube 8x8x8 demo and to be honest, it impressed me. At that moment, my hands had been scratching something for a long time to create something like that. Then I did not know what Arduino was, and in general I had vague notions even of how to connect the LED correctly. Gaining courage, I went to the Internet, where I quickly found ideas and schemes for how to assemble such cubes, and a store where you can buy components. I chose a 4x4x4 cube as the best option for the first experiment.


    A bit of theory and a line of thought:
    How to light an LED?
    Apply voltage and connect ground. Power 5V - need a resistor.
    How to light 16 diodes with the ability to ignite separately?
    Need 16 keys to supply voltage.
    How to light any diode from a 4x4x4 matrix?
    We lay out the matrix on the "floors" 4 to 4. We get 16 keys for voltage on the "poles" + 4 to open the earth on the "floor".

    In total, 20 controlled outputs of a certain microcontroller are needed.
    I did not dare to solder the strapping and program from scratch the microcontroller without experience and chose Arduino, or rather an analog of Freeduino.
    Freeduino Nano v5
    Microcontroller: ATmega328
    Digital input / output ports: 14 ports (6 of them with a PWM signal)
    Analog input ports: 8 ports

    22 programmable inputs / outputs with voltage + 5V for a logical unit - that’s what you need.

    Materials:
    LEDs 64pcs
    Resistors 20 pcs.
    Bipolar Transistors 4 pcs.
    MK: Freeduino Nano v5
    Wiring, switch, connectors, breadboards and more.
    LEDs and Freeduino were bought at the nearest store; the rest was soldered from the nearest power supply or found elsewhere.

    So,
    here we go : We mark something into squares with sides 5mm by 5mm - this is the length of the short leg of the LED.


    We bend the cathode 90 degrees - we will solder them into a chain, receiving "floors" and beautifully expose them to the template matrix obtained earlier.


    Next, bend the anode (long leg) at a slight angle. This is required to conveniently solder the "floors"




    and solder everything together.

    It's time to test.
    Because the LEDs were blue, found a blue loop and dismissed it.


    When it all worked on a breadboard of joy there was no chapel.

    We collect the pedestal.
    It just so happened that I bought exactly 64 LEDs and one was lost. I don’t have a store where I could buy on the way, and it’s very strange to order delivery due to one diode. The solution was found by itself - to put the cube on a truncated edge! And the original and appearance only wins. The box from the discs just fit in size. For reliability and the possibility of tripping, a switch has been fused into it that blocks the earth.


    Next are photos of the already updated version. The first cube collected fell victim to a local cataclysm and was irretrievably lost except the base. To collect the updated version, I no longer bent the legs, because they are very soft and do not hold well, I cut them almost to the root, and made connections from 0.9 mm steel wire from a hardware store. Fuss turned out more, but the result is much better. Smoother edges, and the rigidity of the structure has increased. I already took diodes from the Chinese and assembled a complete 4x4x4 cube.


    What's inside:


    And the result:


    It is powered by any 5V source. Most often connected to a USB port. For programming, it is necessary to turn off the cube so that it does not glow. because outputs 0 and 1 were used, which are also used to program the controller. When the illumination is on and the program is running, current flows through the outputs, which leads to failures in 90% of cases when a new sketch is uploaded.

    I did not write about the Arduino IDE and cite the code . Simple cycles - nothing interesting and there are a lot of examples already on the Internet.
    If anyone gets interested, I’ll add a code and shoot a video.

    Diamond sketch
    /*
    Rombik Arduino. Created by Azurius
     */
    int i,z,x,c,v,b,a,s,d;
    int dt = 100;
    int dts = 2;
    int nprog =1;
    int tmp1=0, tmp2=0, tmp3=0;
    int timeb=0, timew=0;
    int LEDM[4][4] = 
    {
      4,5,6,7,
      8,9,10,11,
      16,17,18,19,
      15,14,12,13};
    int LEDF[4] = {
      3,2,0,1};
    int ma[12]={
      4,5,6,7,11,19,13,12,14,15,16,8}; 
    int mas[4]={
      0,3,12,15};
    void setup() {                
      for (i=0;i<4;i++){
        for (z=0;z<4;z++){
          pinMode(LEDM[i][z], OUTPUT);     
        }
      }
      for (i=0;i<4;i++){
        pinMode(LEDF[i], OUTPUT);
      }
     LedOFFAll(); //tushim vse pered nachalom
    }
    void LedON(int pin){
      digitalWrite(pin, HIGH);
    }
    void LedOFF(int pin){
      digitalWrite(pin, LOW);
    }
    void DotON(int kx, int ky, int kz){
     LedON(LEDM[kx][ky]);
     LedON(LEDF[kz]); 
    }
    void DotOFF(int kx,int ky, int kz){
     LedOFF(LEDM[kx][ky]);
     LedOFF(LEDF[kz]); 
    }
    void LedOFFAll(){
      for (i=0;i<4;i++){
        for (z=0;z<4;z++){
          LedOFF(LEDM[i][z]);     
        }
        LedOFF(LEDF[i]);
      }
    }
    void change(){
      timew=millis();
      if ((timew-timeb)>=10000){nprog++;timeb=millis();dt=70;}
      if (nprog==10) nprog=1;
    }
    void loop() {
     change();
    //nprog = 0;
     //##########[## Prog 0 ##############
     // ALL ON
      if (nprog==0){
        // ON begin
       for (c=0;c<4;c++){
       LedON(LEDF[c]);
          for (i=0;i<4;i++){
          for (z=0;z<4;z++){
            LedON(LEDM[i][z]);
           delay(300);
            LedOFF(LEDM[i][z]);
            }
          }
           LedOFF(LEDF[c]);
         }
      } // end nprog 0
      //############ Prog 1 ##############
      // zajigaet po ocheredi tochkami
      if (nprog==1){
        // ON begin 
        for (c=0;c<4;c++){
          for (i=0;i<4;i++){
          for (z=0;z<4;z++){
            DotON(i,z,c);
            delay(dt);
            DotOFF(i,z,c);
           }
         }
       }
      } // end nprog 1
      //############ Prog 2 ##############
      // zajigaem stolbiki po ocheredi
      if (nprog==2){
        // ON begin 
        for (c=0;c<4;c++){
            LedON(LEDF[c]);
        }
          for (i=0;i<4;i++){
            for (z=0;z<4;z++){
              LedON(LEDM[i][z]);
              delay(dt);
            }
          }
          for (i=0;i<4;i++){
            for (z=0;z<4;z++){
              delay(dt);
              LedOFF(LEDM[i][z]);
            }
          }
      } // end nprog 2
      //############ Prog 3 ##############
      // zajigaem etaji po ocheredi
      if (nprog==3) { 
        // ON begin 
        for (i=0;i<4;i++){
          for (z=0;z<4;z++){
            //LedON(LEDF[c]);
            LedON(LEDM[i][z]);
          }
        }
        for (c=0;c<4;c++){
          LedON(LEDF[c]);
          delay(dt);
          LedOFF(LEDF[c]);     
        }
      LedOFFAll();
      } //end nprog 3
      //############ Prog 4 ##############
      //  Zmeyka po granyam 
    if (nprog ==4){
     dt=30;
      while(1){
      x=v;
      v=random(0,3);
      if(x!=v){break;}
    }
    if(v==0){if(i==0){
                  for(b=0;b<4;b++){i=b;DotON(i,z,c); delay(dt); DotOFF(i,z,c);}}
             else{
                  for(b=3;b>-1;b--){i=b;DotON(i,z,c); delay(dt); DotOFF(i,z,c);}}
      }
    if(v==1){if(z==0){
                 for(b=0;b<4;b++){z=b;DotON(i,z,c); delay(dt); DotOFF(i,z,c);}}
             else{
                 for(b=3;b>-1;b--){z=b;DotON(i,z,c); delay(dt); DotOFF(i,z,c);}}
      }
    if(v==2){if(c==0){
                 for(b=0;b<4;b++){c=b;DotON(i,z,c); delay(dt); DotOFF(i,z,c);}}
             else{  
                 for(b=3;b>-1;b--){c=b;DotON(i,z,c); delay(dt); DotOFF(i,z,c);}}
     }
      } //end nprog 4
      //############ Prog 5 ##############
      // goryashie grani
      if (nprog == 5){
          for (c=0;c<4;c++){
          LedON(LEDF[c]);
          for (i=0;i<12;i++){
            LedON(ma[i]);
            if (c==1 | c==2){
              i=i+2;
            }
          }
          delay(dts);
          LedOFF(LEDF[c]);
          for (i=0;i<12;i++){
            LedOFF(ma[i]);
          }
        }  
      }// end nprog 5
      //############ 6 ###########
      // ploskosti po ocheredi
      if (nprog==6){
        // ON begin
           for (i=0;i<4;i++){
          LedON(LEDM[i][0]);
          LedON(LEDM[i][3]);
          LedON(LEDF[i]);
        }
        delay(1000);
        LedOFFAll();    
        for (i=0;i<4;i++){
          LedON(LEDM[0][i]);
          LedON(LEDM[3][i]);
          LedON(LEDF[i]);
        }
        delay(1000);
        LedOFFAll();    
      } //end nprog 6
    //############ 7 ###########
    if (nprog==7){
      i=random(0,4);
      z=random(0,4);
      c=random(0,4);
            DotON(i,z,c);
            delay(dt);
            DotOFF(i,z,c);
      } //end nprog 7
    //############ 8 ###########
    if (nprog==8){
    //random up
      i=random(0,4);
      z=random(0,4);
      v=random(0,4);
      b=random(0,4);
      a=random(0,4);
      s=random(0,4);
    LedON(LEDM[i][z]);
    LedON(LEDM[v][b]);
    LedON(LEDM[a][s]);
       for (c=0;c<4;c++){
           LedON(LEDF[c]);
            delay(dt);
           LedOFF(LEDF[c]);
          }
    LedOFF(LEDM[i][z]);
    LedOFF(LEDM[v][b]);
    LedOFF(LEDM[a][s]);
      } //end nprog 8
    //############ 8 ###########
    if (nprog==9){
    //obhod po krugu
    LedOFFAll();
    for(c=0;c<4;c++){
    LedON(LEDF[c]);
    }
    for(i=0;i<12;i++){
    LedON(ma[i]);
    delay(dt);
    if(i>1){LedOFF(ma[i-2]);}
    }
    } //end nprog 9 
    } // end loop
    


    Led romb


    Thanks for attention.

    Z.Y. Reviewing the article before publishing, I saw the edge of the mug stand. I feel the questions “what's under the mug?”.
    Here:

    Glued with a glue gun.

    Also popular now: