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);
}
}