Snake on home-made 6x6 matrix - Button issue

Hi all !

I've build and soldered a 6x6 led matrix, and my goal is to play snake on it. I've retrieved some code online, made for a 8x8 matrix, and made some adaptation. It almost works ! This matrix is without multiplexing for now. Once this will work, I plan to use multiplexers to do a bigger matrix.

But for now, I have an issue with the buttons. I have one for the snake to go left, and one for the snake to go right. But currently clicking on the buttons doesn't work, and hence here I am, hopping that one of you can help me.

You'll find the code on here, with lots of comments to help you guys to understand it.

The diagram looks like this one, but for 6x6 matrix, all on digital In/Out, with the needed resistors (1k Ohm resistors before each row (positive input of each LED)). Pins 2 to 7 are for columns (negative pins of LEDs), and 8 to 13 for rows (positive pins). The buttons are on pins 0 and 1 for right and left. I also still need to add the transistors.

If you'd like to see what it looks like in real life, there's a youtube video here (it shows a "ghosting issue" that has now been solved, thanks to PaulRB)

I hope someone here can help me ! Let me know if you need any more information to do so.

The buttons are on pins 0 and 1

// Pin used from the arduino
const unsigned int leftButton = 1;              				// Input pin for button 1
const unsigned int rightButton = 0;     

Serial.begin(9600);

Is it a good idea to use the hardware serial pins for your buttons?

The analog pins (say A0 and A1) can be used as (are) digital pins.

Hi !

Thank you for your answer :slight_smile: Problem is now solved.

I had two issues :

  1. Using analog pins rather than digital ones helped
  2. The direction of the snake has been set to "static", which made it stay the same all along the way when the program runs (see explanation here of "static")

Now I'll try to scale that up with a multiplexer and transistors, and do something more elegant than a few soldered leds :slight_smile: