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