School Tetris project.

im in my last year of school so I have to make a big project called a PWS (dutch for Profiel WerkStuk). I want to study electrical engineering major mechatronics so I thought making Tetris is a good starting project.

The problem I have is that I dont know how to make the code that I can send to my shift register to remember that he has to remember the last leds so he can always let them on. I want to make the leds stack when they tough eachother, like in tetris! Can someone help me? For now im going bit by bit and just with 2x8 leds with 1 shift register. This is my code for now.

//Zeggen welke pin bij wat hoort.
int Data = 2;
int Store = 3;
int clockShift = 4;
int Links = 5;
int Rechts = 6;

byte Leds = 0;

void updateShiftRegister() {
digitalWrite(Store, LOW);
shiftOut(Data, clockShift, LSBFIRST, Leds);
digitalWrite(Store, HIGH);
}

void setup() {
//zeggen wat een input en wat een output is.
pinMode(Data, OUTPUT);
pinMode(Store, OUTPUT);
pinMode(clockShift, OUTPUT);
pinMode(Links, OUTPUT);
pinMode(Rechts, OUTPUT);

}
// de loop om er voor te zorgen dat alle leds van boven naar beneden gaan.
void loop() {
digitalWrite(Rechts, HIGH);
digitalWrite(Links, LOW);
for (int i = 0; i < 8; i++) {
Leds = 1 << i;
updateShiftRegister();
delay(1000);
}
}

There is a Nederlands section of this forum if it would help to be able to discuss the problem in Dutch. If you would like your post moved than please use the Report to moderator link to request it to be moved.

I prefer to be english because there are more people that speak english then dutch. But tanks I will also post it there and wait for replies.

If I understand correctly, you're going to want to keep a copy of the LED array in memory. That will keep track of the LEDs and your shifter logic just needs to write the patterns in that array out.

As a simple example, suppose your grid is 8 LEDs x 8 LEDs. You could represent each LED as a bit in an array of eight (8) bytes:

byte grGridArray[8];
.
.
.

example:
byte 0: 0 0 0 0 0 0 0 0 <- top row
byte 1: 0 0 0 0 0 0 0 0
byte 2: 0 0 1 0 0 0 0 0 <-\
byte 3: 0 0 1 1 1 1 0 0 <- shape dropping in from top
byte 4: 0 0 0 0 0 0 0 0
byte 5: 0 1 0 0 0 0 1 0
byte 6: 1 1 0 0 0 0 1 0
byte 7: 1 1 1 1 1 1 1 0 <- bottom row

Do you have a wiring diagram showing how your LEDs are wired to the shift register(s)?

I am using 1 led matrix 8x8 and 2 shift registers 1 going to the arduino the shift register with the extra pin to the next shift register.