Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * by zer044 arduino account holder
- * 25/08/2011
- * 3by3 Led cube read from array
- **/
- int levelPins[] = {22,23,24};
- int colPins[] = {30,31,32,33,34,35,36,37,38};
- int x=0;
- int x=y;
- int first[3][9] = {
- {1, 1, 1, 0, 0, 0, 0, 0, 0},
- {1, 1, 1, 0, 0, 0, 0, 0, 0},
- {1, 1, 1, 0, 0, 0, 0, 0, 0},
- };
- int second[3][9] = {
- {0, 0, 0, 1, 1, 1, 0, 0, 0},
- {0, 0, 0, 1, 1, 1, 0, 0, 0},
- {0, 0, 0, 1, 1, 1, 0, 0, 0},
- };
- int third[3][9] = {
- {0, 0, 0, 0, 0, 0, 1, 1, 1},
- {0, 0, 0, 0, 0, 0, 1, 1, 1},
- {0, 0, 0, 0, 0, 0, 1, 1, 1},
- };
- int all[3][9] = {
- {1, 1, 1, 1, 1, 1, 1, 1, 1},
- {1, 1, 1, 1, 1, 1, 1, 1, 1},
- {1, 1, 1, 1, 1, 1, 1, 1, 1},
- };
- void setup () {
- //set all output
- for (int i=0; i<3; i++) {
- pinMode(levelPins[i], OUTPUT);
- }
- for (int j=0; j<9; j++) {
- pinMode(colPins[j], OUTPUT);
- }
- }
- void show (int image[3][9]) {
- for (int level=0; level<3; level++) {
- digitalWrite(levelPins[level], LOW);
- for (int col=0; col < 9; col++) {
- int pixel = image[level][col];
- if (pixel == 1) {digitalWrite(colPins[col], HIGH);}
- delayMicroseconds(30);
- digitalWrite(colPins[col], LOW);
- } // col for
- digitalWrite(levelPins[level], HIGH);
- } // level for
- } // end of show
- void loop()
- {
- show(first);
- show(second);
- show(third);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement