Blogroll

Powered by Blogger.

Wednesday 1 October 2014

Algorithm and Program to Turn on Diagonal LEDs of 2*2*2 LED Cube (Part 11 of 13)

by realfinetime  |  in LED Cube at  22:52

<<<<  Read Previous Part (Part 10)

          Previous portion of this topic is given in the last page. Algorithm and arduino program for the working of 2*2*2 LED cube by persistence of vision can be demonstrated as shown below.

          Turn on LED 5 first. Then turn off LED 5 and turn on LED 3 within 1/16th part of that second at which LED 5 was turned on. Then, turn off LED 3 and turn on LED 5 again within 1/16th part of that second at which LED 3 was turned on. This will give an illusion to our eyes that LED 5 and LED 3 are ON because of persistence of vision. Following program will implement this algorithm to turn on LED 3 and LED 5 together.


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;

// 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() {

  //Turn on LED 3  
  for(i=0;i<25;i++)
  {
    digitalWrite(f, HIGH);   
    digitalWrite(e, LOW);   
    digitalWrite(d, LOW); 
    digitalWrite(c, HIGH);
    digitalWrite(b, HIGH);  
    digitalWrite(a, HIGH);  
  }

  //Turn off LED 7
  digitalWrite(f, LOW);   
  digitalWrite(e, LOW);  

  //Turn on LED 5  
  for(i=0;i<25;i++)
  {
    digitalWrite(f, LOW);    
    digitalWrite(e, HIGH);  
    digitalWrite(d, HIGH);  
    digitalWrite(c, HIGH);   
    digitalWrite(b, HIGH);  
    digitalWrite(a, LOW);     
  }
 
  //Turn off LED 5
  digitalWrite(f, LOW);  
  digitalWrite(e, LOW);   
  
}

          If uploading is successful, LED 3 and LED 5 will turn on. In the program, there is an "i" loop. This loop is for keeping the LEDs in the ON state for a few milliseconds. By changing the upper limit of "i" loop, we can adjust the brightness of LEDs.

Continued in Next Part (Part 12)  >>>>

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.