Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <math.h>
- int leftOneLED = 8;
- int leftTwoLED = 9;
- int leftThreeLED = 2;
- int leftFourLED = 3;
- int rightOneLED = 4;
- int rightTwoLED = 5;
- int rightThreeLED = 6;
- int rightFourLED = 7;
- int row01 = 52;
- int row02 = 42;
- int row03 = 53;
- int row04 = 46;
- int row05 = 39;
- int row06 = 51;
- int row07 = 41;
- int row08 = 47;
- int row09 = 36;
- int row10 = 26;
- int row11 = 37;
- int row12 = 30;
- int row13 = 23;
- int row14 = 35;
- int row15 = 25;
- int row16 = 31;
- int colBot01 = 44;
- int colBot02 = 43;
- int colBot03 = 45;
- int colBot04 = 50;
- int colBot05 = 49;
- int colBot06 = 48;
- int colBot07 = 40;
- int colBot08 = 38;
- int colTop01 = 28;
- int colTop02 = 27;
- int colTop03 = 29;
- int colTop04 = 34;
- int colTop05 = 33;
- int colTop06 = 32;
- int colTop07 = 24;
- int colTop08 = 22;
- bool pieceI[8] = {true, true, true, true, false, false, false, false};
- bool pieceJ[8] = {false, false, false, true, false, true, true, true};
- bool pieceL[8] = {false, true, true, true, false, false, false, true};
- bool pieceO[8] = {false, false, true, true, false, false, true, true};
- bool pieceS[8] = {false, true, true, false, false, false, true, true};
- bool pieceT[8] = {false, true, true, true, false, false, true, false};
- bool pieceZ[8] = {false, false, true, true, false, true, true, false};
- const byte rowsBot[] = {row01,row02,row03,row04,row05,row06,row07,row08};
- const byte rowsTop[] = {row09,row10,row11,row12,row13,row14,row15,row16};
- const byte colsBot[] = {colBot08,colBot07,colBot06,colBot05,colBot04,colBot03,colBot02,colBot01};
- const byte colsTop[] = {colTop08,colTop07,colTop06,colTop05,colTop04,colTop03,colTop02,colTop01};
- byte bytes[256] = {B11111111,B11111110,B11111101,B11111100,B11111011,B11111010,B11111001,B11111000,B11110111,B11110110,B11110101,B11110100,B11110011,B11110010,B11110001,B11110000,
- B11101111,B11101110,B11101101,B11101100,B11101011,B11101010,B11101001,B11101000,B11100111,B11100110,B11100101,B11100100,B11100011,B11100010,B11100001,B11100000,
- B11011111,B11011110,B11011101,B11011100,B11011011,B11011010,B11011001,B11011000,B11010111,B11010110,B11010101,B11010100,B11010011,B11010010,B11010001,B11010000,
- B11001111,B11001110,B11001101,B11001100,B11001011,B11001010,B11001001,B11001000,B11000111,B11000110,B11000101,B11000100,B11000011,B11000010,B11000001,B11000000,
- B10111111,B10111110,B10111101,B10111100,B10111011,B10111010,B10111001,B10111000,B10110111,B10110110,B10110101,B10110100,B10110011,B10110010,B10110001,B10110000,
- B10101111,B10101110,B10101101,B10101100,B10101011,B10101010,B10101001,B10101000,B10100111,B10100110,B10100101,B10100100,B10100011,B10100010,B10100001,B10100000,
- B10011111,B10011110,B10011101,B10011100,B10011011,B10011010,B10011001,B10011000,B10010111,B10010110,B10010101,B10010100,B10010011,B10010010,B10010001,B10010000,
- B10001111,B10001110,B10001101,B10001100,B10001011,B10001010,B10001001,B10001000,B10000111,B10000110,B10000101,B10000100,B10000011,B10000010,B10000001,B10000000,
- B01111111,B01111110,B01111101,B01111100,B01111011,B01111010,B01111001,B01111000,B01110111,B01110110,B01110101,B01110100,B01110011,B01110010,B01110001,B01110000,
- B01101111,B01101110,B01101101,B01101100,B01101011,B01101010,B01101001,B01101000,B01100111,B01100110,B01100101,B01100100,B01100011,B01100010,B01100001,B01100000,
- B01011111,B01011110,B01011101,B01011100,B01011011,B01011010,B01011001,B01011000,B01010111,B01010110,B01010101,B01010100,B01010011,B01010010,B01010001,B01010000,
- B01001111,B01001110,B01001101,B01001100,B01001011,B01001010,B01001001,B01001000,B01000111,B01000110,B01000101,B01000100,B01000011,B01000010,B01000001,B01000000,
- B00111111,B00111110,B00111101,B00111100,B00111011,B00111010,B00111001,B00111000,B00110111,B00110110,B00110101,B00110100,B00110011,B00110010,B00110001,B00110000,
- B00101111,B00101110,B00101101,B00101100,B00101011,B00101010,B00101001,B00101000,B00100111,B00100110,B00100101,B00100100,B00100011,B00100010,B00100001,B00100000,
- B00011111,B00011110,B00011101,B00011100,B00011011,B00011010,B00011001,B00011000,B00010111,B00010110,B00010101,B00010100,B00010011,B00010010,B00010001,B00010000,
- B00001111,B00001110,B00001101,B00001100,B00001011,B00001010,B00001001,B00001000,B00000111,B00000110,B00000101,B00000100,B00000011,B00000010,B00000001,B00000000
- };
- byte topDisplay[8] = {B11111111, B11111111, B11111111, B11111111, B11111111, B11111111, B11111111, B11111111};
- byte botDisplay[8] = {B11111111, B11111111, B11111111, B11111111, B11111111, B11111111, B11111111, B11111111};
- int topDisplayInts[8] = {0,0,0,0,0,0,0,0};
- int botDisplayInts[8] = {0,0,0,0,0,0,0,0};
- int pieceCoords[8] = {-1,-1,-1,-1,-1,-1,-1,-1};
- bool colsMatrix[8][16] = {
- {false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false},
- {false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false},
- {false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false},
- {false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false},
- {false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false},
- {false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false},
- {false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false},
- {false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}
- };
- bool lockedMatrix[8][16] = {
- {false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false},
- {false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false},
- {false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false},
- {false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false},
- {false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false},
- {false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false},
- {false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false},
- {false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}
- };
- String curPiece = "";
- String nextPiece = "";
- int fallSpeed = 18; //frames per line dropped
- int frLeftPressed = -1;
- int frRightPressed = -1;
- int dasFrame = -1;
- void setup() {
- Serial.begin(9600);
- randomSeed(analogRead(A0));
- // put your setup code here, to run once:
- int i;
- int a;
- for(i=2;i<10;i++)
- {
- pinMode(i, OUTPUT);
- }
- for(a=22;a<54;a++)
- {
- pinMode(a, OUTPUT);
- }
- pinMode(11, INPUT);
- pinMode(12, INPUT);
- pinMode(13, INPUT);
- nextPiece = generateNextPiece();
- int failed = spawnPiece();
- }
- void loop() {
- // put your main code here, to run repeatedly:
- //drawScreen(topDisplay, false);
- //nextPiece = generateNextPiece();
- //displayNextPiece(nextPiece);
- drawScreen(topDisplay, false);
- drawScreen(botDisplay, true);
- displayNextPiece(nextPiece);
- int frame = millis() * 60 / 1000 + 1;
- int failed;
- //DAS!!!!
- //15 frame startup
- //With DAS, 6 frames per shift
- if(digitalRead(11) == 1)
- {
- //Right
- frLeftPressed = -1;
- if(frRightPressed == -1)
- {
- int a;
- bool canShift = true;
- for(a=0;a<4;a++)
- {
- if(pieceCoords[2 * a] == 0 || lockedMatrix[pieceCoords[2 * a] - 1][pieceCoords[2 * a + 1]])
- {
- canShift = false;
- }
- }
- if(canShift)
- {
- Serial.println("Shift");
- shiftMatrices(true);
- pieceCoords[0] -= 1;
- pieceCoords[2] -= 1;
- pieceCoords[4] -= 1;
- pieceCoords[6] -= 1;
- updateDisplay();
- }
- frRightPressed = frame;
- }
- else
- {
- if(frame - frRightPressed >= 15 && dasFrame == -1)
- {
- dasFrame = frame;
- }
- else if(dasFrame != -1)
- {
- //in DAS
- if((frame - dasFrame) % 6 == 0)
- {
- int a;
- bool canShift = true;
- for(a=0;a<4;a++)
- {
- if(pieceCoords[2 * a] == 0 || lockedMatrix[pieceCoords[2 * a] - 1][pieceCoords[2 * a + 1]])
- {
- canShift = false;
- }
- }
- if(canShift)
- {
- Serial.println("Shift");
- shiftMatrices(true);
- pieceCoords[0] -= 1;
- pieceCoords[2] -= 1;
- pieceCoords[4] -= 1;
- pieceCoords[6] -= 1;
- updateDisplay();
- }
- }
- }
- }
- }
- else if(digitalRead(12) == 1)
- {
- //Left
- frRightPressed = -1;
- if(frLeftPressed == -1)
- {
- int a;
- bool canShift = true;
- for(a=0;a<4;a++)
- {
- if(pieceCoords[2 * a] == 7 || lockedMatrix[pieceCoords[2 * a] + 1][pieceCoords[2 * a + 1]])
- {
- canShift = false;
- }
- }
- if(canShift)
- {
- Serial.println("Shift");
- shiftMatrices(false);
- pieceCoords[0] += 1;
- pieceCoords[2] += 1;
- pieceCoords[4] += 1;
- pieceCoords[6] += 1;
- updateDisplay();
- }
- frLeftPressed = frame;
- }
- else
- {
- if(frame - frLeftPressed >= 15 && dasFrame == -1)
- {
- dasFrame = frame;
- }
- else if(dasFrame != -1)
- {
- //in DAS
- if((frame - dasFrame) % 6 == 0)
- {
- int a;
- bool canShift = true;
- for(a=0;a<4;a++)
- {
- if(pieceCoords[2 * a] == 7 || lockedMatrix[pieceCoords[2 * a] + 1][pieceCoords[2 * a + 1]])
- {
- canShift = false;
- }
- }
- if(canShift)
- {
- Serial.println("Shift");
- shiftMatrices(false);
- pieceCoords[0] += 1;
- pieceCoords[2] += 1;
- pieceCoords[4] += 1;
- pieceCoords[6] += 1;
- updateDisplay();
- }
- }
- }
- }
- }
- else
- {
- frLeftPressed = -1;
- frRightPressed = -1;
- dasFrame = -1;
- }
- if(frame % fallSpeed == 0)
- {
- int d = dropPiece();
- clearLines();
- if(d == 1)
- {
- failed = spawnPiece();
- }
- }
- }
- void clearLines()
- {
- bool cleared[16] = {true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true};
- bool someToClear = false;
- int n = 0;
- int i;
- int l;
- for(i=0;i<16;i++)
- {
- for(l=0;l<8;l++)
- {
- if(!lockedMatrix[l][i])
- {
- cleared[i] = false;
- }
- }
- if(cleared[i])
- {
- someToClear = true;
- }
- }
- if(someToClear)
- {
- int j;
- int k;
- int n = 1;
- int seq = 0;
- for(k=15;k>=1;k--)
- {
- if(cleared[k - 1])
- {
- n++;
- if(seq > 0)
- {
- seq--;
- }
- if(cleared[k - 2])
- {
- n++;
- seq++;
- if(cleared[k - 3])
- {
- n++;
- seq++;
- }
- }
- }
- if(n>0)
- {
- for(j=0;j<8;j++)
- {
- if(k - n - seq < 0)
- {
- colsMatrix[j][k] = false;
- lockedMatrix[j][k] = false;
- }
- else
- {
- colsMatrix[j][k] = colsMatrix[j][k - n - seq];
- lockedMatrix[j][k] = lockedMatrix[j][k - n - seq];
- }
- }
- }
- }
- int m;
- for(m=0;m<8;m++)
- {
- colsMatrix[m][0] = false;
- lockedMatrix[m][0] = false;
- }
- }
- updateDisplay();
- }
- void shiftMatrices(bool R)
- {
- if(R)
- {
- int i;
- int j;
- for(i=0;i<4;i++)
- {
- colsMatrix[pieceCoords[2 * i] - 1][pieceCoords[2 * i + 1]] = colsMatrix[pieceCoords[2 * i]][pieceCoords[2 * i + 1]];
- lockedMatrix[pieceCoords[2 * i] - 1][pieceCoords[2 * i + 1]] = lockedMatrix[pieceCoords[2 * i]][pieceCoords[2 * i + 1]];
- colsMatrix[pieceCoords[2 * i]][pieceCoords[2 * i + 1]] = false;
- lockedMatrix[pieceCoords[2 * i]][pieceCoords[2 * i + 1]] = false;
- }
- }
- else
- {
- int i;
- int j;
- for(i=3;i>=0;i--)
- {
- colsMatrix[pieceCoords[2 * i] + 1][pieceCoords[2 * i + 1]] = colsMatrix[pieceCoords[2 * i]][pieceCoords[2 * i + 1]];
- lockedMatrix[pieceCoords[2 * i] + 1][pieceCoords[2 * i + 1]] = lockedMatrix[pieceCoords[2 * i]][pieceCoords[2 * i + 1]];
- colsMatrix[pieceCoords[2 * i]][pieceCoords[2 * i + 1]] = false;
- lockedMatrix[pieceCoords[2 * i]][pieceCoords[2 * i + 1]] = false;
- }
- }
- }
- void dropMatrices()
- {
- int i;
- int j;
- for(i=0;i<8;i++)
- {
- for(j=15;j>=1;j--)
- {
- if(!lockedMatrix[i][j] && !lockedMatrix[i][j - 1])
- {
- colsMatrix[i][j] = colsMatrix[i][j - 1];
- lockedMatrix[i][j] = lockedMatrix[i][j - 1];
- }
- }
- colsMatrix[i][0] = false;
- lockedMatrix[i][0] = false;
- }
- }
- int dropPiece()
- {
- delay(1);
- bool canDrop = true;
- if(pieceCoords[1] == 15 || pieceCoords[3] == 15 || pieceCoords[5] == 15 || pieceCoords[7] == 15)
- {
- canDrop = false;
- }
- else if(lockedMatrix[pieceCoords[0]][pieceCoords[1] + 1] || lockedMatrix[pieceCoords[2]][pieceCoords[3] + 1] ||
- lockedMatrix[pieceCoords[4]][pieceCoords[5] + 1] || lockedMatrix[pieceCoords[6]][pieceCoords[7] + 1])
- {
- canDrop = false;
- }
- if(canDrop)
- {
- pieceCoords[1] += 1;
- pieceCoords[3] += 1;
- pieceCoords[5] += 1;
- pieceCoords[7] += 1;
- }
- else
- {
- int i;
- for(i=0;i<4;i++)
- {
- lockedMatrix[pieceCoords[2 * i]][pieceCoords[2 * i + 1]] = true;
- }
- updateDisplay();
- return 1;
- }
- dropMatrices();
- updateDisplay();
- return 0;
- }
- void updateDisplay()
- {
- int k;
- int l;
- for(k=0;k<8;k++)
- {
- topDisplayInts[k] = 0;
- botDisplayInts[k] = 0;
- for(l=0;l<8;l++)
- {
- if(colsMatrix[k][l])
- {
- topDisplayInts[k] += 128 / pow(2, l);
- }
- if(colsMatrix[k][l + 8])
- {
- botDisplayInts[k] += 128 / pow(2, l);
- }
- }
- topDisplay[k] = bytes[topDisplayInts[k]];
- botDisplay[k] = bytes[botDisplayInts[k]];
- }
- }
- int spawnPiece()
- {
- int returnOut = 0;
- Serial.println("Spawning " + nextPiece + " piece.");
- curPiece = nextPiece;
- /*if(nextPiece == "I")
- {
- if(colsMatrix[2][0] || colsMatrix[3][0] || colsMatrix[4][0] || colsMatrix[5][0])
- {
- returnOut = 1;
- }
- colsMatrix[2][0] = true;
- colsMatrix[3][0] = true;
- colsMatrix[4][0] = true;
- colsMatrix[5][0] = true;
- int i;
- for(i=0;i<8;i++)
- {
- if(i % 2 == 0)
- {
- pieceCoords[i] = i / 2 + 2;
- }
- else
- {
- pieceCoords[i] = 0;
- }
- }
- }
- if(nextPiece == "J")
- {
- if(colsMatrix[2][0] || colsMatrix[2][1] || colsMatrix[3][0] || colsMatrix[4][0])
- {
- returnOut = 1;
- }
- colsMatrix[2][0] = true;
- colsMatrix[2][1] = true;
- colsMatrix[3][0] = true;
- colsMatrix[4][0] = true;
- pieceCoords[0] = 2;
- pieceCoords[1] = 0;
- pieceCoords[2] = 2;
- pieceCoords[3] = 1;
- pieceCoords[4] = 3;
- pieceCoords[5] = 0;
- pieceCoords[6] = 4;
- pieceCoords[7] = 0;
- }
- if(nextPiece == "L")
- {
- if(colsMatrix[2][0] || colsMatrix[3][0] || colsMatrix[4][0] || colsMatrix[4][1])
- {
- returnOut = 1;
- }
- colsMatrix[2][0] = true;
- colsMatrix[3][0] = true;
- colsMatrix[4][0] = true;
- colsMatrix[4][1] = true;
- pieceCoords[0] = 2;
- pieceCoords[1] = 0;
- pieceCoords[2] = 3;
- pieceCoords[3] = 0;
- pieceCoords[4] = 4;
- pieceCoords[5] = 0;
- pieceCoords[6] = 4;
- pieceCoords[7] = 1;
- }*/
- if(nextPiece == "O")
- {
- if(colsMatrix[3][0] || colsMatrix[3][1] || colsMatrix[4][0] || colsMatrix[4][1])
- {
- returnOut = 1;
- }
- colsMatrix[3][0] = true;
- colsMatrix[3][1] = true;
- colsMatrix[4][0] = true;
- colsMatrix[4][1] = true;
- pieceCoords[0] = 3;
- pieceCoords[1] = 0;
- pieceCoords[2] = 3;
- pieceCoords[3] = 1;
- pieceCoords[4] = 4;
- pieceCoords[5] = 0;
- pieceCoords[6] = 4;
- pieceCoords[7] = 1;
- }
- /*if(nextPiece == "S")
- {
- if(colsMatrix[2][0] || colsMatrix[3][0] || colsMatrix[3][1]| colsMatrix[4][1])
- {
- returnOut = 1;
- }
- colsMatrix[2][0] = true;
- colsMatrix[3][0] = true;
- colsMatrix[3][1] = true;
- colsMatrix[4][1] = true;
- pieceCoords[0] = 2;
- pieceCoords[1] = 0;
- pieceCoords[2] = 3;
- pieceCoords[3] = 0;
- pieceCoords[4] = 3;
- pieceCoords[5] = 1;
- pieceCoords[6] = 4;
- pieceCoords[7] = 1;
- }
- if(nextPiece == "T")
- {
- if(colsMatrix[2][0] || colsMatrix[3][0] || colsMatrix[3][1] || colsMatrix[4][0])
- {
- returnOut = 1;
- }
- colsMatrix[2][0] = true;
- colsMatrix[3][0] = true;
- colsMatrix[3][1] = true;
- colsMatrix[4][0] = true;
- pieceCoords[0] = 2;
- pieceCoords[1] = 0;
- pieceCoords[2] = 3;
- pieceCoords[3] = 0;
- pieceCoords[4] = 3;
- pieceCoords[5] = 1;
- pieceCoords[6] = 4;
- pieceCoords[7] = 0;
- }
- if(nextPiece == "Z")
- {
- if(colsMatrix[2][1] || colsMatrix[3][0] || colsMatrix[3][1] || colsMatrix[4][0])
- {
- returnOut = 1;
- }
- colsMatrix[2][1] = true;
- colsMatrix[3][0] = true;
- colsMatrix[3][1] = true;
- colsMatrix[4][0] = true;
- pieceCoords[0] = 2;
- pieceCoords[1] = 1;
- pieceCoords[2] = 3;
- pieceCoords[3] = 0;
- pieceCoords[4] = 3;
- pieceCoords[5] = 1;
- pieceCoords[6] = 4;
- pieceCoords[7] = 0;
- }*/
- updateDisplay();
- nextPiece = generateNextPiece();
- return returnOut;
- }
- void drawScreen(byte buffer2[], bool bottom) // FIGURE OUT PINS FOR MATRICES
- {
- if(bottom)
- {
- // Turn on each row in series
- for (byte i = 0; i < 8; i++) // count next row
- {
- digitalWrite(rowsBot[i], HIGH); //initiate whole row
- for (byte a = 0; a < 8; a++) // count next row
- {
- // if You set (~buffer2[i] >> a) then You will have positive
- digitalWrite(colsBot[a], (buffer2[i] >> a) & 0x01); // initiate whole column
- delayMicroseconds(100); // uncoment deley for diferent speed of display
- //delayMicroseconds(1000);
- //delay(10);
- //delay(100);
- digitalWrite(colsBot[a], 1); // reset whole column
- }
- digitalWrite(rowsBot[i], LOW); // reset whole row
- // otherwise last row will intersect with next row
- }
- }
- else
- {
- // Turn on each row in series
- for (byte i = 0; i < 8; i++) // count next row
- {
- digitalWrite(rowsTop[i], HIGH); //initiate whole row
- for (byte a = 0; a < 8; a++) // count next row
- {
- // if You set (~buffer2[i] >> a) then You will have positive
- digitalWrite(colsTop[a], (buffer2[i] >> a) & 0x01); // initiate whole column
- delayMicroseconds(100); // uncoment deley for diferent speed of display
- //delayMicroseconds(1000);
- //delay(10);
- //delay(100);
- digitalWrite(colsTop[a], 1); // reset whole column
- }
- digitalWrite(rowsTop[i], LOW); // reset whole row
- // otherwise last row will intersect with next row
- }
- }
- }
- String generateNextPiece()
- {
- /*String pieces[7] = {"I", "J", "L", "O", "S", "T", "Z"};
- long randNumber = random(0,714) / 102;
- int randIndex = (int) floor(randNumber);
- String nP = pieces[randIndex];
- return nP;*/
- return "O";
- }
- void displayNextPiece(String piece)
- {
- int i;
- if(piece == "I")
- {
- for(i=0;i<8;i++)
- {
- if(pieceI[i])
- {
- if(i == 0 || i == 1)
- {
- digitalWrite(i + 8, HIGH);
- }
- else
- {
- digitalWrite(i, HIGH);
- }
- }
- else
- {
- if(i == 0 || i == 1)
- {
- digitalWrite(i + 8, LOW);
- }
- else
- {
- digitalWrite(i, LOW);
- }
- }
- }
- }
- if(piece == "J")
- {
- for(i=0;i<8;i++)
- {
- if(pieceJ[i])
- {
- if(i == 0 || i == 1)
- {
- digitalWrite(i + 8, HIGH);
- }
- else
- {
- digitalWrite(i, HIGH);
- }
- }
- else
- {
- if(i == 0 || i == 1)
- {
- digitalWrite(i + 8, LOW);
- }
- else
- {
- digitalWrite(i, LOW);
- }
- }
- }
- }
- if(piece == "L")
- {
- for(i=0;i<8;i++)
- {
- if(pieceL[i])
- {
- if(i == 0 || i == 1)
- {
- digitalWrite(i + 8, HIGH);
- }
- else
- {
- digitalWrite(i, HIGH);
- }
- }
- else
- {
- if(i == 0 || i == 1)
- {
- digitalWrite(i + 8, LOW);
- }
- else
- {
- digitalWrite(i, LOW);
- }
- }
- }
- }
- if(piece == "O")
- {
- for(i=0;i<8;i++)
- {
- if(pieceO[i])
- {
- if(i == 0 || i == 1)
- {
- digitalWrite(i + 8, HIGH);
- }
- else
- {
- digitalWrite(i, HIGH);
- }
- }
- else
- {
- if(i == 0 || i == 1)
- {
- digitalWrite(i + 8, LOW);
- }
- else
- {
- digitalWrite(i, LOW);
- }
- }
- }
- }
- if(piece == "S")
- {
- for(i=0;i<8;i++)
- {
- if(pieceS[i])
- {
- if(i == 0 || i == 1)
- {
- digitalWrite(i + 8, HIGH);
- }
- else
- {
- digitalWrite(i, HIGH);
- }
- }
- else
- {
- if(i == 0 || i == 1)
- {
- digitalWrite(i + 8, LOW);
- }
- else
- {
- digitalWrite(i, LOW);
- }
- }
- }
- }
- if(piece == "T")
- {
- for(i=0;i<8;i++)
- {
- if(pieceT[i])
- {
- if(i == 0 || i == 1)
- {
- digitalWrite(i + 8, HIGH);
- }
- else
- {
- digitalWrite(i, HIGH);
- }
- }
- else
- {
- if(i == 0 || i == 1)
- {
- digitalWrite(i + 8, LOW);
- }
- else
- {
- digitalWrite(i, LOW);
- }
- }
- }
- }
- if(piece == "Z")
- {
- for(i=0;i<8;i++)
- {
- if(pieceZ[i])
- {
- if(i == 0 || i == 1)
- {
- digitalWrite(i + 8, HIGH);
- }
- else
- {
- digitalWrite(i, HIGH);
- }
- }
- else
- {
- if(i == 0 || i == 1)
- {
- digitalWrite(i + 8, LOW);
- }
- else
- {
- digitalWrite(i, LOW);
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement