Blogroll

Powered by Blogger.

Thursday 2 October 2014

Animation of a Simple Pattern in 2*2*2 LED Cube by Arduino Mega (Part 12 of 13)

by realfinetime  |  in LED Cube at  01:21

<<<<  Read Previous Part (Part 11)

Create a Simple Pattern in a 2*2*2 LED Cube

          We had seen the arduino program to turn on disgonal LEDs of a 2*2*2 LED cube in previous blog. Here we will create a simple pattern in the 2*2*2 LED cube using arduino.


Circuit is given here. Complete that circuit and upload the following program to your arduino board.

int f = 8;  //Connect "f" terminal of LED Cube to 8th pin of arduino
int e = 9;  //Connect "e" terminal of LED Cube to 9th pin of arduino
int d = 10; //Connect "d" terminal of LED Cube to 10th pin of arduino
int c = 11; //Connect "c" terminal of LED Cube to 11th pin of arduino
int b = 12; //Connect "b" terminal of LED Cube to 12th pin of arduino
int a = 13; //Connect "a" terminal of LED Cube to 13th pin of arduino

int i=0, j=0, upper_limit=15, delay_time=100;

// the setup routine runs once when you press reset:
void setup() {                
  // initialize the digital pin as an output.
  pinMode(f, OUTPUT);
  pinMode(e, OUTPUT);
  pinMode(d, OUTPUT);
  pinMode(c, OUTPUT);
  pinMode(b, OUTPUT);
  pinMode(a, OUTPUT);   
}

// the loop routine runs over and over again forever:
void loop() {

  for(j=0;j<delay_time;j++)
  {
  
    for(i=0;i<upper_limit;i++)
    {
      //turn on LED 3
      digitalWrite(f, HIGH);   
      digitalWrite(e, LOW);   
      digitalWrite(d, LOW); 
      digitalWrite(c, HIGH);
      digitalWrite(b, HIGH);  
      digitalWrite(a, HIGH);  

      //turn on LED 4
      digitalWrite(f, HIGH);   
      digitalWrite(e, LOW);   
      digitalWrite(d, HIGH); 
      digitalWrite(c, LOW);
      digitalWrite(b, HIGH);  
      digitalWrite(a, HIGH);
    }

    //Turn off LED 3 and LED 4
    digitalWrite(f, LOW);   
    digitalWrite(e, LOW);  

 
    for(i=0;i<upper_limit;i++)
    {
      //turn on LED 5
      
      digitalWrite(f, LOW);    
      digitalWrite(e, HIGH);  
      digitalWrite(d, HIGH);  
      digitalWrite(c, HIGH);   
      digitalWrite(b, HIGH);  
      digitalWrite(a, LOW);   
  
      //turn on LED 6
  
      digitalWrite(f, LOW);    
      digitalWrite(e, HIGH);  
      digitalWrite(d, HIGH);  
      digitalWrite(c, HIGH);   
      digitalWrite(b, LOW);  
      digitalWrite(a, HIGH);   
    }
 
    //Turn off LED 5 and LED 6
    digitalWrite(f, LOW);  
    digitalWrite(e, LOW);   
  } 
  
  
  
  for(j=0;j<delay_time;j++)
  {
  
    for(i=0;i<upper_limit;i++)
    {
      
      //turn on LED 7
      
      digitalWrite(f, LOW);   
      digitalWrite(e, HIGH);   
      digitalWrite(d, LOW); 
      digitalWrite(c, HIGH);
      digitalWrite(b, HIGH);  
      digitalWrite(a, HIGH);  
    
      //turn on LED 8
    
      digitalWrite(f, LOW);   
      digitalWrite(e, HIGH);   
      digitalWrite(d, HIGH); 
      digitalWrite(c, LOW);
      digitalWrite(b, HIGH);  
      digitalWrite(a, HIGH);
    }

    //turn off LED 7 and LED 8
    digitalWrite(f, LOW);   
    digitalWrite(e, LOW);  


 
    for(i=0;i<upper_limit;i++)
    {
      
      //turn on LED 1
      
      digitalWrite(f, HIGH);    
      digitalWrite(e, LOW);  
      digitalWrite(d, HIGH);  
      digitalWrite(c, HIGH);   
      digitalWrite(b, HIGH);  
      digitalWrite(a, LOW);   
  
      //turn on LED 2
  
      digitalWrite(f, HIGH);    
      digitalWrite(e, LOW);  
      digitalWrite(d, HIGH);  
      digitalWrite(c, HIGH);   
      digitalWrite(b, LOW);  
      digitalWrite(a, HIGH);   
    }
 
    //turn off LED 1 and LED 2
    
    digitalWrite(f, LOW);  
    digitalWrite(e, LOW);   
  } 
  
}

          If uploading is successful, a pattern given at the top of this page will be created in your LED cube. By changing the value of "upper_limit", we can adjust the brightness of LEDs. Similarly, by changing the value of "delay_time", we can adjust the speed of illumination.

Continued in Next Part (Part 13)  >>>>

0 comments:

IMPORTANT NOTICE

All the circuits, published in this blog is only after testing and getting proper results in my private lab. When you try these circuits, you should check the supply voltage, polarity of components, presence of childrens nearby and shorts in the circuits. This website will not be responsible for any harm happened to you or your components caused by your carelessness.

For More Electronic Tips



Blog Archive

Proudly Powered by Blogger.