4x4 keypad to control 74HC595's

Hello I am brand new to arduino, but i do a little coding in python, and ready to learn. I am trying to control 300 different LED’s with a 4x4 keypad, and multiple 74HC595’s. To get the general concept i would like help tying to numbers from the keypad to LED’s in their order. Similar to this that i found on tinkercad.

#include <Wire.h>

int x = 0;
int leds[]={0,0,0,0,0,0,0,0,0,0,0,0,0};

void allOff() {
  for(int i=2; i<=9; i++) {

void setup() {

void receiveEvent(int bytes) {
  x = Wire.read();

void loop() {
  for(int i=2; i<=9; i++) {
  if(x>0) {
    if((x>='0') && (x<='9')) {
    Serial.print(" ");

this does what i am after, but i would like to use at least two 74HC595’s and have at least 16 LED’s so i can get the idea. I am hoping after that i can take it and run with it. Thanks for reading and hopefully some one out there can help me. Thanks

You’re in the right area.

Once you’ve got your LED states in the array, you can just shift them out to the 595s.

To make it easier for yourself, turn leds into the bits of a single unsigned int… bits 0::15 (16 LEDs)

Then once you’ve set the required bits in that integer, you can shift them out directly- either using the shiftOut() function, or bit-bashing the bits of ‘led’. In this case, no array needed, but there are later reasons you may like to introduce complexity, but get one thing working first!

Wow thanks for the quick reply. Sorry should have mentioned i did not write that code; it is a code snippet from the corresponding image pulled from a project someone else made on tinkercad. I will try to work out what changes i need to make from your reply but will more then likely come back with something broken as your reply seems to assume i have a much higher level of proficiency then i do. Which is of course my fault as i put up code that is functional but not of my own making. Thanks a lot @lastchancename . I will submit a topic sequel when i have a reached my skill limits.

1 Like

300/8 = 38 shift registers, with a current limit resistor needed per LED.

If you use MAX7219 instead, each controlling 64 LEDs, then only 5 chips are needed.
Each MAX7219 is essentially 8 shift registers, and you will only need one current setting resistor per chip, saving you a lot of components.

You will need a 10uF, a 0.1uF, and a 10K resistor per chip.

I offer a board that brings out a pair of wires per LED if that will help with wiring:

This shows it with female headers, most folks ask for male headers instead and you can use 30 AWG wire wrap wire from the males pins to the LED legs as I did here:

that sounds great but i can’t find that component on tinkercad. Is there a different browser based prototyper that has it available?

While the MAX7219 sounds awesome. I have completed a design and would like confirmation that i have not massively overlooked something before i try to code anything for this.


“{“message”:“User Login Required.”,“error”:{“status”:401,“message”:“User Login Required.”}}” Problem with the link you provided.

I hope you have seen this or don’t need to:

But please tell us what your goal is. The picture with two Arduinos where one would suffice makes me wonder.

And 300 pixels using shift registers means maybe you haven’t heard of Neopixels or other so-called “smart” LEDs. If you haven’t, I invite you to google a bit on that. For many deployment scenarios they make things much easier. Or as hard perhaps but in different ways.

Are you just trying to learn more about keypads and shift registers and communication amongst multiple processors


do you actually have in mind a real project that needs 300 LEDs and a keypad somehow?


what are you up to?

The more details you provide, the better we can help.

BTW we have been asked, since it’s your first time here, to welcome you. Welcome!


Does tinkercad allow you to create your own symbols?
A 28-pin DIP is pretty basic.
Maybe take a 328P and start from there, renaming the pins as needed:
Max7219 datasheet

Atmega328P datasheet

Thanks for all the responses. I am trying to create a 6’ tall, 3’ wide, and 1’ deep structure that has leds all over it in specific locations that will eventually relay information. 300 may not be the final total; I just know it will be hundreds. I want to start with a keypad so i can: (A) get proof of concept in what appears to me to be the simplest way, (B) learn the basics of addressing LEDs and activating them from another source, and (C) keep a port for a key pad for possible future trouble shooting. Eventually i will try to tie this to a bluetooth app that allows me to light up the structure through different actions taken in the app that don’t implicitly call out numbers in the user input, but correspond to the different addressed LEDs to give IRL user feed back from digital actions taken. The reason i have 2 Arduinos is this is a project on Tinkercad that is a Frankenstein of 2 other projects that had been posted there. I was not sure if they where right or wrong just that they separately achieved a small version of my desired end goal, so i do not have a reason for the second Arduino other then that i knew it had been making the first example work and I didn’t want to break that.

Here’s 4 MAX7219s controlling 256 LEDs controlled by an Uno or Duemilanove.

Controlling them from another source would be straightforward.
Send in simple message, like
xxx, 0 or xxx, 1, where xxx is the LED number, and 0 or 1 is off or on.

The controlling Arduino then maps xxx into MAX7219 1 to 5, and then into register 1 to 8 of each device.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.