<<<< Read Previous Part (Part 8)
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 7
Upload the following program to your arduino board. If uploading is successful, LED 7 will start blinking.
Program to blink LED 8
Upload the following program to your arduino board. If uploading is successful, LED 8 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 7
Upload the following program to your arduino board. If uploading is successful, LED 7 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 7 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, LOW); //Send LOW 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 7 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 8
Upload the following program to your arduino board. If uploading is successful, LED 8 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 8 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, LOW); //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, HIGH); //Send LOW to the "a" terminal of LED cube delay(500); //Turn off LED 8 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 10) >>>> |
0 comments: