switch matrix anti ghosting

i have a set of pins that are set to INPUT_PULLUP
and a set of pins that are set to OUTPUT
to scan the keys i write the output pins 'low'
and read the input of the INPUT_PULLUP pins

how do i attatch diodes to prevent ghosting?
also, does output pins written low act as ground?

One way is to have a diode in series with every switch.

Yes, you can think of a pin set to OUTPUT and LOW as connected to ground inside the Arduino. OUTPUT and HIGH means the pin is connected to 5V inside the Arduino. A pin set to INPUT is not connected to either GND or 5V. A pin set to INPUT_PULLUP is connected to 5V with a resistor of around 50 K.

What are your OUTPUT pins set to when they are not LOW? Take care: if they are set to HIGH you could press multiple switches and cause a short damaging the Arduino. I would recommend you set those OUTPUT pins to INPUT when they are not LOW.

Paul

, does output pins written low act as ground?

Yes.

See the schematic here for what I did for an 8 by 8 switch matrix
http://www.thebox.myzen.co.uk/Hardware/Econo_Monome.html

the OUTPUT pins are set to HIGH yes
if it is going to damage the board, what should i do to prevent it?

thanks for the helpful replies

Grumpy_Mike:
Yes.

See the schematic here for what I did for an 8 by 8 switch matrix
http://www.thebox.myzen.co.uk/Hardware/Econo_Monome.html

i tried to understand it, but the schematic is too overwhelming
i am a complete noob at this so i dont understand what means what
sorry but thank you

Read this:


.

for(byte rowTemp=0;rowTemp<6;rowTemp++){
pinMode(rowPin[rowTemp],OUTPUT);
digitalWrite(rowPin[rowTemp],LOW); //make row pins work as ground one by one
for(byte colTemp=0;colTemp<15;colTemp++){
keystate[15rowTemp+colTemp]=!digitalRead(colPin[colTemp]); //read keys that are pressed, one row at a time
if(keystate[15
rowTemp+colTemp]!=prevKeystate[15rowTemp+colTemp]){ //if the keystate has changed,
stateChanged[15
rowTemp+colTemp]=millis(); //save the current time to debounce the key
}
}
pinMode(rowPin[rowTemp],INPUT); //reset the row pins to their former state
}

the colPins are INPUT_PULLUPs

LarryD:
Read this:
How a Key Matrix Work


.

so in my case, the output of this article would be my INPUT_PULLUP?
sorry if this question seems nooby i am a noob

thanks for the reply

coolnumber0129:
the OUTPUT pins are set to HIGH yes
if it is going to damage the board, what should i do to prevent it?

I told you in the same paragraph.

But the code you posted above does not set them to HIGH. It sets them to INPUT like I suggested:

    pinMode(rowPin[rowTemp],INPUT);                                                 //reset the row pins to their former state

PaulRB:
I told you in the same paragraph!

yes i changed it according to what you said
but i forgot to mention it here
thanks!