SHARE
TWEET

My 4x4x4

Al_Ninyo Jan 9th, 2015 220 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Initalize our LED columns (positive)
  2. int LEDPin[] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
  3. // Initalize the LED layers (ground)
  4. int LayerPin[] = {16,17,18,19};
  5. int count = 0;
  6.  
  7. void setup(){
  8.   // Set up LED columns as output
  9.   for(int pin = 0; pin < 16 ; pin++ ){
  10.     pinMode(LEDPin[pin],OUTPUT);
  11.     digitalWrite(LEDPin[pin],LOW);
  12.   }
  13.   // Set up LED Layers as output
  14.   for(int layer = 0; layer < 4; layer++){
  15.     pinMode(LayerPin[layer], OUTPUT);
  16.     digitalWrite(LayerPin[layer], HIGH);
  17.   }
  18. }
  19.  
  20. void loop(){
  21.   // Set up LED columns as output
  22.   for(int pin = 0; pin < 16 ; pin++ ){
  23.     digitalWrite(LEDPin[pin],LOW);
  24.   }
  25.   // Set up LED Layers as output
  26.   for(int layer = 0; layer < 4; layer++){
  27.     digitalWrite(LayerPin[layer], HIGH);
  28.   }  
  29.   count = 1;
  30.   while(count < 3){
  31.   //One layer
  32.   for(int pin = 0; pin < 16 ; pin++ ){
  33.     digitalWrite(LEDPin[pin],HIGH);
  34.   }
  35.   for(int layer = 0; layer < 4; layer++){
  36.   digitalWrite(LayerPin[layer],LOW);
  37.   delay(50);
  38.  
  39.   digitalWrite(LayerPin[layer],HIGH);
  40.   delay(10);
  41.   }
  42.  
  43.   for(int layer = 2; layer >= 1; layer--){
  44.   digitalWrite(LayerPin[layer],LOW);
  45.   delay(50);
  46.  
  47.   digitalWrite(LayerPin[layer],HIGH);
  48.   delay(10);
  49.   }
  50.   count++;
  51.   }
  52.     // Set up LED columns as output
  53.   for(int pin = 0; pin < 16 ; pin++ ){
  54.     digitalWrite(LEDPin[pin],LOW);
  55.   }
  56.   // Set up LED Layers as output
  57.   for(int layer = 0; layer < 4; layer++){
  58.     digitalWrite(LayerPin[layer], HIGH);
  59.   }
  60.  
  61.   //4 columns
  62.   for(int layer = 0; layer < 4; layer++){
  63.     digitalWrite(LayerPin[layer], LOW);
  64.   }
  65.   count = 1;
  66.   while(count < 3){
  67.   for(int pin = 0; pin < 4 ; pin++ ){
  68.     digitalWrite(LEDPin[(0+pin)],HIGH);
  69.     digitalWrite(LEDPin[(4+pin)],HIGH);
  70.     digitalWrite(LEDPin[(8+pin)],HIGH);
  71.     digitalWrite(LEDPin[(12+pin)],HIGH);
  72.     delay(50);
  73.     digitalWrite(LEDPin[(0+pin)],LOW);
  74.     digitalWrite(LEDPin[(4+pin)],LOW);
  75.     digitalWrite(LEDPin[(8+pin)],LOW);
  76.     digitalWrite(LEDPin[(12+pin)],LOW);
  77.   }
  78.   for(int pin = 3; pin >= 0 ; pin-- ){
  79.     digitalWrite(LEDPin[(0+pin)],HIGH);
  80.     digitalWrite(LEDPin[(4+pin)],HIGH);
  81.     digitalWrite(LEDPin[(8+pin)],HIGH);
  82.     digitalWrite(LEDPin[(12+pin)],HIGH);
  83.     delay(50);
  84.     digitalWrite(LEDPin[(0+pin)],LOW);
  85.     digitalWrite(LEDPin[(4+pin)],LOW);
  86.     digitalWrite(LEDPin[(8+pin)],LOW);
  87.     digitalWrite(LEDPin[(12+pin)],LOW);
  88.   }
  89.   count++;
  90.   }
  91.  
  92.   //1 columns
  93.   for(int layer = 0; layer < 4; layer++){
  94.     digitalWrite(LayerPin[layer], LOW);
  95.   }
  96.  
  97.    for(int pin = 0; pin < 16 ; pin++ ){
  98.     digitalWrite(LEDPin[pin],HIGH);
  99.     delay(50);
  100.     digitalWrite(LEDPin[pin],LOW);
  101.   }
  102.   for(int pin = 14; pin >= 0 ; pin-- ){
  103.     digitalWrite(LEDPin[pin],HIGH);
  104.     delay(50);
  105.     digitalWrite(LEDPin[pin],LOW);
  106.   }
  107.  
  108.   //_aA
  109.   count = 1;
  110.   while(count < 5){
  111.   digitalWrite(LayerPin[0],LOW);
  112.   for(int pin = 0; pin < 4 ; pin++ ){
  113.     digitalWrite(LEDPin[(4*pin)],HIGH);
  114.   }
  115.    delay(100);
  116.   for(int pin = 0; pin < 4 ; pin++ ){
  117.     digitalWrite(LEDPin[(4*pin)],LOW);
  118.   }
  119.   digitalWrite(LayerPin[1],LOW);
  120.   for(int pin = 0; pin < 4 ; pin++ ){
  121.     digitalWrite(LEDPin[(4*pin+1)],HIGH);
  122.   }
  123.    delay(100);
  124.   for(int pin = 0; pin < 4 ; pin++ ){
  125.     digitalWrite(LEDPin[(4*pin+1)],LOW);
  126.   }
  127.   digitalWrite(LayerPin[2],LOW);
  128.   for(int pin = 0; pin < 4 ; pin++ ){
  129.     digitalWrite(LEDPin[(4*pin+2)],HIGH);
  130.   }
  131.    delay(100);
  132.   for(int pin = 0; pin < 4 ; pin++ ){
  133.     digitalWrite(LEDPin[(4*pin+2)],LOW);
  134.   }
  135.   digitalWrite(LayerPin[3],LOW);
  136.   for(int pin = 0; pin < 4 ; pin++ ){
  137.     digitalWrite(LEDPin[(4*pin+3)],HIGH);
  138.   }
  139.    delay(100);
  140.   for(int pin = 0; pin < 4 ; pin++ ){
  141.     digitalWrite(LEDPin[(4*pin+3)],LOW);
  142.   }
  143.   digitalWrite(LayerPin[1],HIGH);
  144.   digitalWrite(LayerPin[2],HIGH);
  145.   digitalWrite(LayerPin[3],HIGH);
  146.  
  147.   //reverse (Aa_)
  148.   digitalWrite(LayerPin[3],HIGH);
  149.   digitalWrite(LayerPin[2],LOW);
  150.   for(int pin = 0; pin < 4 ; pin++ ){
  151.     digitalWrite(LEDPin[(4*pin+2)],HIGH);
  152.   }
  153.    delay(100);
  154.   for(int pin = 0; pin < 4 ; pin++ ){
  155.     digitalWrite(LEDPin[(4*pin+2)],LOW);
  156.   }
  157.   digitalWrite(LayerPin[1],HIGH);
  158.   digitalWrite(LayerPin[2],HIGH);
  159.  
  160.   digitalWrite(LayerPin[0],LOW);
  161.   for(int pin = 0; pin < 4 ; pin++ ){
  162.     digitalWrite(LEDPin[(4*pin)],HIGH);
  163.   }
  164.    delay(100);
  165.   for(int pin = 0; pin < 4 ; pin++ ){
  166.     digitalWrite(LEDPin[(4*pin)],LOW);
  167.   }
  168.   digitalWrite(LayerPin[0],HIGH);
  169.   count++;
  170.   }
  171.  
  172.   //helicopter
  173.   count = 1;
  174.   while(count < 5){
  175.   for(int layer = 0; layer < 4; layer++){
  176.     digitalWrite(LayerPin[layer], LOW);
  177.     digitalWrite(LEDPin[5],HIGH);
  178.     digitalWrite(LEDPin[6],HIGH);
  179.     digitalWrite(LEDPin[9],HIGH);
  180.     digitalWrite(LEDPin[10],HIGH);
  181.  
  182.   for(int pin = 0; pin < 4 ; pin++ ){
  183.     digitalWrite(LEDPin[pin],HIGH);
  184.     digitalWrite(LEDPin[(15-pin)],HIGH);
  185.     delay(30);
  186.     digitalWrite(LEDPin[pin],LOW);
  187.     digitalWrite(LEDPin[(15-pin)],LOW);
  188.   }
  189.   for(int pin = 0; pin < 4 ; pin++ ){
  190.     digitalWrite(LEDPin[(4*pin+3)],HIGH);
  191.     digitalWrite(LEDPin[(12-4*pin)],HIGH);
  192.     delay(30);
  193.     digitalWrite(LEDPin[(4*pin+3)],LOW);
  194.     digitalWrite(LEDPin[(12-4*pin)],LOW);
  195.   }
  196.   digitalWrite(LayerPin[layer], HIGH);
  197.  }
  198.   count++;
  199.   }
  200. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top