Help Needed: 74HC595s + Tetris Codes + Custom Built 8x8 LED Matrix

Hi there,

I am in desperate need of some help with this. I am trying to get a small 4 x 4 LED matrix to work with the Tetris codes from http://jocker.tistory.com/164 (the original source codes and a video are available over there) Here are the connections that I have made and other relevant details,

(A) 74HC595s
Shift Register 1 (Pins 1-8)

  1. Top of LED Matrix (Left to Right): LEDs 1-4 ,
  2. 2nd Row of LED Matrix (Left to Right): LEDs 5-8.

Shift Register 2 (Pins 1-8)

  1. 3rd Row of LED Matrix (Left to Right): LEDs 9-12,
  2. Bottom/Last Row of LED Matrix (Left to Right): LEDs 13-16.

(B) LEDs
I noticed a rollPin in the original code so I have,

  • Anodes (+) of LEDs 1-4 connected to Digital Pin 3
  • Anodes (+) of LEDs 5-8 connected to Digital Pin 4
  • Anodes (+) of LEDs 9-12 connected to Digital Pin 5
  • Anodes (+) of LEDs 13-16 connected to Digital Pin 6

(C) Buttons
pinMode(A5, INPUT); //up
pinMode(A2, INPUT); //right
pinMode(A4, INPUT); //left
pinMode(A3, INPUT); //down

These are correct.

(D) A Note
I do NOT want any block rotations at all so I nulled the rest after 0. I just want a single [1][1] block.

Because the original code is meant for a 8x8 LED matrix like one of these (jolliFactory: Bi-color LED Matrix Driver Module DIY Kit), I am terribly confused with how to edit the code accordingly to work with my current setup. I have attached my current edit, which includes the comments by the original author of the Tetris code (Jae Yeong Bae). Can someone help me please? o Thank you~!

(I will scale it up to 8 x 8 after I manage to understand how to fiddle with it properly)

tetrisv2b.ino (23.9 KB)

I also do not quite understand this part (from original author's code),

void LEDRefresh()
{
int i;
int k;

////////////////////////////////////////////////
// I soldered pins wrong. (12345670 instead of 01234567).
// so this portion of code is to software correct this issue.

boolean tmpdisp[8][16];
for (k=0;k<16;k++)
{
for(i=1;i<8;i++)

{
tmpdisp*[k]=disp[i-1][k];*

  • }*
  • tmpdisp[0][k]=disp[7][k]; *
  • } *
  • //////////////////////////////////////////////*
    [/quote]
    Why is there a "7" at the last part - "disp[7][k]"?

takanofukada:
Why is there a "7" at the last part - "disp[7][k]"?

Because having shifted all the array values up one, he has to put the previous top one back into the bottom of the new array.

Like he says - it is a kludge. Lotsa luck with the rest of the code!