Blogroll

Powered by Blogger.

Wednesday 1 October 2014

How to Program Arduino Mega to Blink LED 4 of 2*2*2 LED Cube (Part 8 of 13)

by realfinetime  |  in LED Cube at  10:44

<<<<  Read Previous Part (Part 7)

          We had seen the circuit for connecting 2*2*2 LED cube to arduino mega in the last blog. Here, we will upload some programs to the arduino board to control LEDs in 2*2*2 LED cube individually.

Program to blink LED 4

          Upload the following program to your arduino board. If uploading is successful, LED 4 will start blinking.

// the setup routine runs once when you press reset:
void setup() {                
  // initialize the digital pin as an output.
  pinMode(8, OUTPUT);
  pinMode(9, OUTPUT);
  pinMode(10, OUTPUT);
  pinMode(11, OUTPUT);
  pinMode(12, OUTPUT);
  pinMode(13, OUTPUT);   
}

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

  //Turn on LED 4 for 500 mS
  digitalWrite(8, HIGH);  //Send HIGH to the "f" terminal of LED cube 
  digitalWrite(9, LOW);   //Send LOW to the "e" terminal of LED cube 
  digitalWrite(10, LOW); //Send LOW to the "d" terminal of LED cube 
  digitalWrite(11, HIGH); //Send HIGH to the "c" terminal of LED cube  
  digitalWrite(12, HIGH); //Send HIGH to the "b" terminal of LED cube 
  digitalWrite(13, HIGH); //Send HIGH to the "a" terminal of LED cube 
  
  delay(500);
  
  //Turn off LED 4 for 500 mS
  digitalWrite(8, LOW);   //Send LOW to the "f" terminal of LED cube 
  digitalWrite(9, LOW);   //Send LOW to the "e" terminal of LED cube 
  
  delay(500);
}


Program to blink LED 5

          Upload the following program to your arduino board. If uploading is successful, LED 5 will start blinking.

// the setup routine runs once when you press reset:
void setup() {                
  // initialize the digital pin as an output.
  pinMode(8, OUTPUT);
  pinMode(9, OUTPUT);
  pinMode(10, OUTPUT);
  pinMode(11, OUTPUT);
  pinMode(12, OUTPUT);
  pinMode(13, OUTPUT);   
}

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

  //Turn on LED 5 for 500 mS
  digitalWrite(8, LOW);   //Send LOW to the "f" terminal of LED cube 
  digitalWrite(9, HIGH);  //Send HIGH to the "e" terminal of LED cube 
  digitalWrite(10, HIGH); //Send HIGH to the "d" terminal of LED cube 
  digitalWrite(11, HIGH); //Send HIGH to the "c" terminal of LED cube  
  digitalWrite(12, HIGH); //Send HIGH to the "b" terminal of LED cube 
  digitalWrite(13, LOW);  //Send LOW to the "a" terminal of LED cube 
  
  delay(500);
  
  //Turn off LED 5 for 500 mS
  digitalWrite(8, LOW);   //Send LOW to the "f" terminal of LED cube 
  digitalWrite(9, LOW);   //Send LOW to the "e" terminal of LED cube 
  
  delay(500);
}


Program to blink LED 6

          Upload the following program to your arduino board. If uploading is successful, LED 6 will start blinking.

// the setup routine runs once when you press reset:
void setup() {                
  // initialize the digital pin as an output.
  pinMode(8, OUTPUT);
  pinMode(9, OUTPUT);
  pinMode(10, OUTPUT);
  pinMode(11, OUTPUT);
  pinMode(12, OUTPUT);
  pinMode(13, OUTPUT);   
}

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

  //Turn on LED 6 for 500 mS
  digitalWrite(8, LOW);  //Send HIGH to the "f" terminal of LED cube 
  digitalWrite(9, HIGH);   //Send LOW to the "e" terminal of LED cube 
  digitalWrite(10, HIGH); //Send HIGH to the "d" terminal of LED cube 
  digitalWrite(11, HIGH);  //Send LOW to the "c" terminal of LED cube  
  digitalWrite(12, LOW); //Send HIGH to the "b" terminal of LED cube 
  digitalWrite(13, HIGH); //Send HIGH to the "a" terminal of LED cube 
  
  delay(500);
  
  //Turn off LED 6 for 500 mS
  digitalWrite(8, LOW);   //Send LOW to the "f" terminal of LED cube 
  digitalWrite(9, LOW);   //Send LOW to the "e" terminal of LED cube 
  
  delay(500);
}


Continued in Next Part (Part 9) >>>>

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.