<<<< Read Previous Part (Part 6)
We had already seen the circuit for 3*3*3 LED cube in previous blog. Here, we will generate a program to create a beautiful pattern as shown below.
Now upload the following program to your arduino board.
If uploading is successful, a pattern as shown in the circuit will be created. By adjusting the value of "delay_time", we can change the speed of pattern.
We had already seen the circuit for 3*3*3 LED cube in previous blog. Here, we will generate a program to create a beautiful pattern as shown below.
Now upload the following program to your arduino board.
int neg1 = 13; //"neg1" is connected to the 13th digital pin of arduino int neg2 = 12; //"neg2" is connected to the 12th digital pin of arduino int neg3 = 11; //"neg3" is connected to the 11th digital pin of arduino int neg4 = 10; //"neg4" is connected to the 10th digital pin of arduino int neg5 = 9; //"neg5" is connected to the 9th digital pin of arduino int neg6 = 8; //"neg6" is connected to the 8th digital pin of arduino int neg7 = 7; //"neg7" is connected to the 7th digital pin of arduino int neg8 = 6; //"neg8" is connected to the 6th digital pin of arduino int neg9 = 5; //"neg9" is connected to the 5th digital pin of arduino int pos1 = 4; //"pos1" is connected to the 4th digital pin of arduino int pos2 = 3; //"pos2" is connected to the 3rd digital pin of arduino int pos3 = 2; //"pos3" is connected to the 2nd digital pin of arduinoint temp; int delay_time=100, i=0; int neg_array[]={neg1, neg2, neg3, neg6, neg9, neg8, neg7, neg4}; int status_array_1[]={LOW, HIGH, HIGH, HIGH, HIGH, HIGH, HIGH, HIGH}; // the setup routine runs once when you press reset: void setup() { // initialize the digital pin as an output. pinMode(neg1, OUTPUT); pinMode(neg2, OUTPUT); pinMode(neg3, OUTPUT); pinMode(neg4, OUTPUT); pinMode(neg5, OUTPUT); pinMode(neg6, OUTPUT); pinMode(neg7, OUTPUT); pinMode(neg8, OUTPUT); pinMode(neg9, OUTPUT); pinMode(pos1, OUTPUT); pinMode(pos2, OUTPUT); pinMode(pos3, OUTPUT); } // the loop routine runs over and over again forever: void loop() { digitalWrite(pos1, HIGH); digitalWrite(pos2, HIGH); digitalWrite(pos3, HIGH); digitalWrite(neg5, HIGH); for(i=0;i<8;i++) { digitalWrite(neg_array[i], status_array_1[i]); } delay(delay_time); temp = status_array_1[7]; for(i=7;i>=0;i--) { status_array_1[i+1] = status_array_1[i]; } status_array_1[0]=temp; }
If uploading is successful, a pattern as shown in the circuit will be created. By adjusting the value of "delay_time", we can change the speed of pattern.
0 comments: