<<<< 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.
Program to blink LED 5
Upload the following program to your arduino board. If uploading is successful, LED 5 will start blinking.
Program to blink LED 6
Upload the following program to your arduino board. If uploading is successful, LED 6 will start blinking.
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: