I need to find the error in this system, I simulate and display on Virtual tesmial is wrong, talented people please help!

Please describe what is wrong, how it is wrong.

What problem are you facing? The problem may exist in your code too.

Are you sure that a 74HC595 shift register is appropriate for reading buttons ? Maybe look at a 74LS166 or other Parallel in Serial out devices instead.

1 Like

I think the circuit is still faulty so I ask about the circuit problem

i mean i did it step by step but when it came to simulation step VT showed wrong, i dont know where it went wrong, i just want to ask if the connection on the circuit is correct, thanks

i think 74166 is no different than 74595, probably not the problem i need to fix, thanks

You have to explain your strategy for scanning the buttons. It appears that you attempt to set a column low and then read a row with a pullup resistor so a low indicates a button press but supplying your code should make this clear.

A 595 register can set the column but I don't believe it can be used to read the rows.

Is the user permitted to press 2 or more buttons simultaneously ?

this is the code of my reference network so not sure if it is correct `#include <SPI.h>

// Define pins for the 74HC595 based on your connections
const int latchPin = 10; // ST_CP pin of 74HC595 connected to pin 10 of Arduino
const int clockPin = 9; // SH_CP pin of 74HC595 connected to pin 9 of Arduino
const int dataPin = 8; // DS pin of 74HC595 connected to pin 8 of Arduino

// Define pins for rows (H1 to H9)
const int rowPins[9] = {2, 3, 4, 5, 6, 7, 8, 9, 10};

void setup() {
// Set up row pins as INPUT_PULLUP
for (int i = 0; i < 9; i++) {
pinMode(rowPins[i], INPUT_PULLUP);
}

// Set up pins for 74HC595 control
pinMode(latchPin, OUTPUT);
pinMode(clockPin, OUTPUT);
pinMode(dataPin, OUTPUT);

// Initialize Serial Monitor
Serial.begin(9600);
}

void loop() {
for (int col = 0; col < 9; col++) {
// Activate the current column
writeColumn(col);

// Check the state of each row
for (int row = 0; row < 9; row++) {
  if (digitalRead(rowPins[row]) == LOW) {
    // If a row is pulled low, it means the button is pressed
    Serial.print("Button at row ");
    Serial.print(row + 1);
    Serial.print(", column ");
    Serial.print(col + 1);
    Serial.println(" is pressed");
  }
}

// Small delay to avoid interference between columns
delay(10);

}
}

void writeColumn(int col) {
// Set value for the current column (only one column is low, others are high)
byte data = ~(1 << col);

digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, MSBFIRST, data);
digitalWrite(latchPin, HIGH);
}
`

I use the method of scanning rows and columns, for example, press the key H1 (row); C1 (column), 1 IC will detect that row 1 has a change in logic level and will give information about row 1 to another IC, IC 2 will scan row 1 and see the logic level change in column 1, from there it will detect that key (1,1) was pressed.

Please use properly format your code with correct indentation and enclose it in code tags. Use google translate (or similar) so the top comment block appears in English.
Here is a good start: How to get the best out of this forum

I copy pasted so it's messy but in my IDE it's aligned correctly

Hi, @040999
Welcome to the forum.

How are you scanning rows when you short them all, H1 to H9 to Vcc?
Top RH corner of the schematic.

Thanks.. Tom... :smiley: :+1: :coffee: :australia:

1 Like

you mean no need to connect H1, .., H9 to VCC

Your circuit makes no sense. Start over. Follow some tutorials to learn how to scan a small button matrix.

You came to this forum for help. If you believe you know more than others on the forum, why did you come here?

The things you think you know are incorrect and this is part of the reason why your circuit is wrong.

By the way, your code is also wrong.

1 Like

I'm not qualified to argue but 74595 is the requirement of this system, sorry for the misunderstanding

Because you did not follow the guidelines as described here: https://forum.arduino.cc/t/how-to-get-the-best-out-of-this-forum/679966#use-code-tags.

1 Like

Ok, imagine the button BT25 is pressed. Can you explain how the circuit and code will detect this.

BT25 is row 7 column 3, I do is initially IC1 scans, if in column 3 there is a key pressed it will change the state to low level, then IC2 will scan to see row 7 has low level from there send signal to adruino

Does this assignment allow you to use 9 digital pins on the Arduino to read the buttons ?
Pins A0 to A5 can also be used as digital pins.