Broken arduino?

Hello, I have been working on a card sorter for the game Magic - The Gathering. My arduino works fine transmitting to the SD card and the LCD screen, but I have not been able to use my previous keyboard. I made a keyboard for my arduino calculator but it doesn't work anymore if I plug it into my new arduino. I have a function that enables typing and it can find out which column the key is in via the shift register but cannot find out the row. I think that this is a bunch of short-circuits inside the arduino because it randomly selects a key and uses that key to print on the LCD screen. I have everything working except for the keyboard. I can attach the files on the SD card and the operating system below:

CODE IN THE MICROCONTROLLER:

#include <SD.h>
#include <LiquidCrystal.h>
File myFile;
int keys=0;
int a=0;
int c=0;
int d=0;
int addon=0;
int STEP=1;
int shift=0;
int keyShift=0;
int key=0;
String addDir="";
String text="";
String prev="";
String value="";
String directory="";
String thingy="";
String folder="";
long int ID=0;
long int deckID=0;
const char keyboard[]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','~','~','~','~','~','~',' ','-',',','\'','~','~','~','~','~','~','~','~','~','~','~','~','~','~','~','~','~','~'};
const char shifts[]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','~','~','~','~','~','~','~','~','~','~','~','~','~','~','~','~','~','~','~','~','~','~','~','~','~','~','~','~'};
LiquidCrystal lcd(A0,A1,A2,A3,A4,A5);
void setup(){
pinMode(7,OUTPUT);
pinMode(8,OUTPUT);
pinMode(9,OUTPUT);
pinMode(2,INPUT);
pinMode(3,INPUT);
pinMode(4,INPUT);
pinMode(5,INPUT);
lcd.begin(20,4);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("MTG Card Sorter by");
lcd.setCursor(0,1);
lcd.print("Pierre Erard,");
lcd.setCursor(0,2);
lcd.print("reading SD card...");
delay(1000);
while(!SD.begin(10)){
delayMicroseconds(10);
}
lcd.clear();
lcd.setCursor(0,0);
lcd.print("SD card ready.");
delay(1000);
}
void loop(){
STEP=1;
folder="";
directory="/OS/STEP1.TXT";
while(SD.exists(directory)){
directory=(String)"/OS"+folder+"/STEP"+String(STEP)+".TXT";
myFile=SD.open(directory);
text="";
while(myFile.available()){
text=text+(char)myFile.read();
}
myFile.close();
value=text;
if(text=="print"){
printLCD(prev);
}
if(text=="resetFolder"){
folder="";
}
if(text=="switch"){
folder=(String)"/"+addDir+String(key);
}
thingy=(String)text[0]+text[1]+text[2]+text[3];
if(thingy.equals("get:")){
convert(String(text[4]));
d=c;
convert(String(text[5]));
key=0;
while(key<d or key>c){
  detectButtons();
}
}
thingy=(String)text[0];
if(thingy=="+"){
addDir=(String)text[1];
}
if(text=="enableTyping"){
value="";
lcd.clear();
lcd.setCursor(0,0);
lcd.print(prev);
lcd.setCursor(0,1);
while(key!=28 or keyShift==0){
  key=0;
  while(key==0){
    detectButtons();
  }
  if(value.length()==20){
    lcd.setCursor(0,2);
  }
  if(value.length()==40){
    lcd.setCursor(0,3);
  }
  if(value.length()<60){
    if(keyShift==1){
      if(shifts[key]!='~'){
        value=value+shifts[key-1];
        lcd.print((String)value[value.length()-1]);
      }
    }else{
      if(keyboard[key]!='~'){
        value=value+keyboard[key-1];
        lcd.print((String)value[value.length()-1]);
      }
    }
  }
}
}
prev=value;
STEP=STEP+1;
}
delay(1000);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("You are logged out.");
delay(1000);
}
void printLCD(String text){
lcd.clear();
lcd.setCursor(0,0);
for(int i=0; i<text.length(); i++){
if(i%20==0){
  lcd.setCursor(0,i/20);
}
lcd.print(text);
}
}
void convert(String integer){
c=0;
for(int b=0;b<integer.length();b++){
c=c*10;
switch(integer){
  case'1':
  c=c+1;
  break;
  case'2':
  c=c+2;
  break;
  case'3':
  c=c+3;
  break;
  case'4':
  c=c+4;
  break;
  case'5':
  c=c+5;
  break;
  case'6':
  c=c+6;
  break;
  case'7':
  c=c+7;
  break;
  case'8':
  c=c+8;
  break;
  case'9':
  c=c+9;
  break;
  case'A':
  c=c+10;
  break;
  case'B':
  c=c+11;
  break;
  case'C':
  c=c+12;
  break;
  case'D':
  c=c+13;
  break;
  case'E':
  c=c+14;
  break;
  case'F':
  c=c+15;
  break;
  case'G':
  c=c+16;
  break;
  case'H':
  c=c+17;
  break;
  case'I':
  c=c+18;
  break;
  case'J':
  c=c+19;
  break;
  case'k':
  c=c+20;
  break;
}
}
}
void detectButtons(){
keys=0;
digitalWrite(7,LOW);
shiftOut(8,9,MSBFIRST,1);
digitalWrite(7,HIGH);
delayMicroseconds(10);
if(digitalRead(2)){
keys=1;
}
if(digitalRead(3)){
keys=8;
}
if(digitalRead(4)){
keys=15;
}
if(digitalRead(5)){
keys=22;
}
digitalWrite(7,LOW);
shiftOut(8,9,MSBFIRST,2);
digitalWrite(7,HIGH);
delayMicroseconds(10);
if(digitalRead(2)){
keys=2;
}
if(digitalRead(3)){
keys=9;
}
if(digitalRead(4)){
keys=16;
}
if(digitalRead(5)){
keys=23;
}
digitalWrite(7,LOW);
shiftOut(8,9,MSBFIRST,4);
digitalWrite(7,HIGH);
delayMicroseconds(10);
if(digitalRead(2)){
keys=3;
}
if(digitalRead(3)){
keys=10;
}
if(digitalRead(4)){
keys=17;
}
if(digitalRead(5)){
keys=24;
}
digitalWrite(7,LOW);
shiftOut(8,9,MSBFIRST,8);
digitalWrite(7,HIGH);
delayMicroseconds(10);
if(digitalRead(2)){
keys=4;
}
if(digitalRead(3)){
keys=11;
}
if(digitalRead(4)){
keys=18;
}
if(digitalRead(5)){
keys=25;
}
digitalWrite(7,LOW);
shiftOut(8,9,MSBFIRST,16);
digitalWrite(7,HIGH);
delayMicroseconds(10);
if(digitalRead(2)){
keys=5;
}
if(digitalRead(3)){
keys=12;
}
if(digitalRead(4)){
keys=19;
}
if(digitalRead(5)){
keys=26;
}
digitalWrite(7,LOW);
shiftOut(8,9,MSBFIRST,32);
digitalWrite(7,HIGH);
delayMicroseconds(10);
if(digitalRead(2)){
keys=6;
}
if(digitalRead(3)){
keys=13;
}
if(digitalRead(4)){
keys=20;
}
if(digitalRead(5)){
keys=27;
}
digitalWrite(7,LOW);
shiftOut(8,9,MSBFIRST,64);
digitalWrite(7,HIGH);
delayMicroseconds(10);
if(digitalRead(2)){
keys=7;
}
if(digitalRead(3)){
keys=14;
}
if(digitalRead(4)){
keys=21;
}
if(digitalRead(5)){
keys=28;
}
keyShift=shift;
key=keys+addon;
if(keys!=0){
if(keys==27){
  shift=1-shift;
  addon=0;
}else if(keys==28&&shift==0){
  addon=28-addon;
}else{
  shift=0;
  addon=0;
}
}
digitalWrite(7,LOW);
shiftOut(8,9,MSBFIRST,127);
digitalWrite(7,HIGH);
delayMicroseconds(10);
while(digitalRead(2)or digitalRead(3)or digitalRead(4)or digitalRead(5)){
delayMicroseconds(10);
}
}

FILES ON THE SD CARD:

/OS/STEP1.TXT: Press 1 to login or 2 to make an account
/OS/STEP2.TXT: print
/OS/STEP3.TXT: get:12
/OS/STEP4.TXT: +A
/OS/STEP5.TXT: switch
/OS/STEP6.TXT:
/OS/A1/STEP6.TXT: Login with username:
/OS/A1/STEP7.TXT: enableTyping

DIRECTORIES:

E:
OS
A1
TOOLS
USERS

EXPLANATION:

The arduino starts up and reads "Press 1 to login or 2 to make an account" off the SD card. The next command prints it on the screen. Then, this is where the problem comes in: It will think that you are pressing keys like "V", "H", etc... because they are in the same row. This can also occur with the previous step if you are trying to press a key and it won't allow you to login. Although there are no users, I tried to test it but the enableTyping function doesn't work on my arduino. The circuit diagram is:

SD card standard connection, LCD screen connected to analog input pins (Yes that does actually work, it displays fine), shift register in pins 7, 8, and 9. Button return pins are 2, 3, 4, and 5. Diodes are used to prevent circuit from powering all wires at once. (I don't know if they are working because I keep getting that problem...) The keys are connected in an array: The shift register outputs a row, and waits to see if there is any input before moving on. If a key is pressed, the arduino can use the output and input via row and collumn method to find the key.

NONE OF THIS WORKED!!! OK: The arduino malfunctioned on the enableTyping and get:12 functions because the pins are broken. Tell me if I need to buy a new arduino or if I am not using my arduino correctly. When I transfered my calculator keyboard and added a few keys, it completely malfunctioned and I had to take it apart. Eventually, I figured out that the problem is inside the arduino itself. I removed the pins and the serial monitor was still giving output on the digitalRead. I got things like 0110, 0111, 0101, and 1110. I think that the arduino needs to be recalibrated because the sensitivity is off. Please help and thanks for reading the whole thing.

Moderator edit:
</mark> <mark>[code]</mark> <mark>

</mark> <mark>[/code]</mark> <mark>
tags added.

I got a new arduino mega 2560 and it also didn't work. The only way I got it to work was by setting the pins next to the key that was being detected to "OUTPUT" and then digitalWriting them to "LOW". After that, it worked fine. I was able to do that because I needed more pins. I don't know why the input glitches on all arduinos. (I can normally make a keyboard fine like I did with my calculator) If your arduino has glitched like that, you may want to consider rewriting the pins from INPUT to OUTPUT and setting them to LOW to make sure that the reading pin can read.

NEW CODE:

#include <SD.h>
#include <LiquidCrystal.h>
File myFile;
int keys=0;
int a=0;
int c=0;
int d=0;
int addon=0;
int STEP=1;
int shift=0;
int keyShift=0;
int key=0;
String addDir="";
String text="";
String prev="";
String value="";
String directory="";
String thingy="";
String folder="";
long int ID=0;
long int deckID=0;
const char keyboard[]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','~','~','~','~','~','~',' ','-',',','\'','~','~','~','~','~','~','~','~','~','~','~','~','~','~','~','~','~','~'};
const char shifts[]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','~','~','~','~','~','~','~','~','~','~','~','~','~','~','~','~','~','~','~','~','~','~','~','~','~','~','~','~'};
LiquidCrystal lcd(2,3,4,5,6,7);
void setup(){
Serial.begin(9600);
for(int i=22;i<50;i++){
  pinMode(i,INPUT);
}
lcd.begin(20,4);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("MTG Card Sorter by");
lcd.setCursor(0,1);
lcd.print("Pierre Erard,");
lcd.setCursor(0,2);
lcd.print("reading SD card...");
delay(1000);
while(!SD.begin(53)){
  delayMicroseconds(10);
}
lcd.clear();
lcd.setCursor(0,0);
lcd.print("SD card ready.");
delay(1000);
}
void loop(){
STEP=1;
folder="";
directory="/OS/STEP1.TXT";
while(SD.exists(directory)){
directory=(String)"/OS"+folder+"/STEP"+String(STEP)+".TXT";
myFile=SD.open(directory);
text="";
while(myFile.available()){
  text=text+(char)myFile.read();
}
myFile.close();
value=text;
if(text=="print"){
 printLCD(prev);
}
if(text=="resetFolder"){
  folder="";
}
if(text=="switch"){
  folder=(String)"/"+addDir+String(key);
}
thingy=(String)text[0]+text[1]+text[2]+text[3];
if(thingy.equals("get:")){
  convert(String(text[4]));
  d=c;
  convert(String(text[5]));
  key=0;
  while(key<d or key>c){
    detectButtons();
  }
}
thingy=(String)text[0];
if(thingy=="+"){
  addDir=(String)text[1];
}
if(text=="enableTyping"){
  value="";
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print(prev);
  lcd.setCursor(0,1);
  while(key!=28 or keyShift==0){
    key=0;
    while(key==0){
      detectButtons();
    }
    if(value.length()==20){
      lcd.setCursor(0,2);
    }
    if(value.length()==40){
      lcd.setCursor(0,3);
    }
    if(value.length()<60){
      if(keyShift==1){
        if(shifts[key]!='~'){
          value=value+shifts[key-1];
          lcd.print((String)value[value.length()-1]);
        }
      }else{
        if(keyboard[key]!='~'){
          value=value+keyboard[key-1];
          lcd.print((String)value[value.length()-1]);
        }
      }
    }
  }
}
prev=value;
STEP=STEP+1;
}
delay(1000);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("You are logged out.");
delay(1000);
}
void printLCD(String text){
lcd.clear();
lcd.setCursor(0,0);
for(int i=0; i<text.length(); i++){
  if(i%20==0){
    lcd.setCursor(0,i/20);
  }
  lcd.print(text[i]);
}
}
void convert(String integer){
c=0;
for(int b=0;b<integer.length();b++){
  c=c*10;
  switch(integer[b]){
    case'1':
    c=c+1;
    break;
    case'2':
    c=c+2;
    break;
    case'3':
    c=c+3;
    break;
    case'4':
    c=c+4;
    break;
    case'5':
    c=c+5;
    break;
    case'6':
    c=c+6;
    break;
    case'7':
    c=c+7;
    break;
    case'8':
    c=c+8;
    break;
    case'9':
    c=c+9;
    break;
    case'A':
    c=c+10;
    break;
    case'B':
    c=c+11;
    break;
    case'C':
    c=c+12;
    break;
    case'D':
    c=c+13;
    break;
    case'E':
    c=c+14;
    break;
    case'F':
    c=c+15;
    break;
    case'G':
    c=c+16;
    break;
    case'H':
    c=c+17;
    break;
    case'I':
    c=c+18;
    break;
    case'J':
    c=c+19;
    break;
    case'k':
    c=c+20;
    break;
  }
}
}
void detectButtons(){
keys=0;
for(int K=1;K<29;K++){
  for(int i=22;i<50;i++){
    if(i-21!=K){
      pinMode(i,OUTPUT);
      digitalWrite(i,LOW);
    }
  }
  pinMode(K+21,INPUT);
  if(digitalRead(K+21)){
    keys=K;
  }
}
key=keys;
Serial.println(key);
if(key!=0){
  pinMode(key+21,INPUT);
  while(digitalRead(key+21)){
    delayMicroseconds(10);
  }
}
}

**Note that this is for the arduino mega. (53 pins)

Moderator edit:
</mark> <mark>[code]</mark> <mark>

</mark> <mark>[/code]</mark> <mark>
tags added.

Does the keypad work with the old arduino ?

Use CTRL T to format your code.
Attach your sketch between code tags, use the </> icon.
[code]Paste your sketch here[/code]

Show us a good schematic & image of your circuit wiring.
Posting images:
http://forum.arduino.cc/index.php?topic=519037.0

noweare:
Does the keypad work with the old arduino ?

It used to, then the arduino broke so I had to change it for the new one. I am also encountering a few problems here too. Although it works fine on detecting, even though I have a while loop waiting for the key release, it can't detect the key release.

(For arduino mega only)
NEW CODE:

#include <SD.h>
#include <LiquidCrystal.h>
File myFile;
int keys=0;
int a=0;
int c=0;
int d=0;
int add=0;
int addon=0;
int STEP=1;
int shift=0;
int keyShift=0;
int key=0;
int iters=0;
int deckNum=0;
int shiftOutput[]={1,2,4,8,16,32,64};
String dir="";
String addDir="";
String text="";
String prev="";
String value="";
String directory="";
String thingy="";
String folder="";
String filename="";
String file="";
String search="";
String result="";
long int ID=0;
long int deckID=0;
const char keyboard[]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','~','~','~','~','~','~',' ','-',',',''','~','~','~','~','~','~','~','~','~','~','~','~','~','~','~','~','~','~'};
const char shifts[]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','~','~','~','~','~','~','~','~','~','~','~','~','~','~','~','~','~','~','~','~','~','~','~','~','~','~','~','~'};
LiquidCrystal lcd(2,3,4,5,6,7);
void setup(){
pinMode(22,INPUT);
pinMode(23,INPUT);
pinMode(24,INPUT);
pinMode(25,INPUT);
pinMode(8,OUTPUT);
pinMode(9,OUTPUT);
pinMode(10,OUTPUT);
lcd.begin(20,4);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("MTG Card Sorter by");
lcd.setCursor(0,1);
lcd.print("Pierre Erard,");
lcd.setCursor(0,2);
lcd.print("reading SD card...");
delay(1000);
while(!SD.begin(53)){
delayMicroseconds(10);
}
lcd.clear();
lcd.setCursor(0,0);
lcd.print("SD card ready.");
delay(1000);
}
void loop(){
if(folder==""){
STEP=1;
directory="/OS/STEP1.TXT";
}else{
folder="";
}
while(SD.exists(directory)){
directory=(String)"/OS"+folder+"/STEP"+String(STEP)+".TXT";
myFile=SD.open(directory);
text="";
while(myFile.available()){
text=text+(char)myFile.read();
}
myFile.close();
value=text;
if(text=="print"){
printLCD(prev);
}
if(text=="ifExist"){
if(SD.exists("/USERS/"+dir+"/"+prev)){
dir=prev;
}else{
STEP=STEP-3;
lcd.clear();
lcd.setCursor(0,0);
lcd.print("This doesn't exist!");
delay(1000);
}
}
if(text=="compile"){
deckNum=0;
search="";
if(prev==""){
lcd.clear();
lcd.setCursor(0,0);
lcd.print("There is nothing to");
lcd.setCursor(0,1);
lcd.print("search.");
delay(1000);
}
while(search!=prev){
search="";
while(deckNum<deckID and !SD.exists("/USERS/"+dir+"/DECK"+String(deckNum)+"/NAME.TXT")){
deckNum=deckNum+1;
}
myFile=SD.open("/USERS/"+dir+"/DECK"+String(deckNum)+"NAME.TXT");
while(myFile.available()){
search=search+(char)myFile.read();
}
myFile.close();
}
if(prev!=""){
search="";
myFile=SD.open("/USERS/"+dir+"/DECK"+String(deckNum)+"/CARDS.TXT");
while(myFile.available()){
while(myFile.available()and myFile.peek()!='~'){
search=search+(char)myFile.read();
}
}
myFile.close();
}
if(SD.exists("/DATABASE/C"+search+"/NAME.TXT")){
myFile=SD.open("/DATABASE/C"+search+"/NAME.TXT");
result="";
while(myFile.available()){
result=result+(char)myFile.read();
}
printLCD(result);
myFile=SD.open("/DATABASE/C"+search+"/COUNT.TXT");
result="";
while(myFile.available()){
result=result+(char)myFile.read();
}
lcd.setCursor(13-String(result).length(),3);
lcd.print(String(result)+" cards");
}else{
lcd.clear();
lcd.setCursor(0,0);
lcd.print("File is corrupted.");
delay(1000);
}
}
if(text=="ifNull,createUser"){
if(SD.exists("/USERS/"+prev)){
STEP=STEP-3;
lcd.clear();
lcd.setCursor(0,0);
lcd.print("User already exists!");
delay(1000);
}else{
SD.mkdir("/USERS/"+prev);
dir=prev;
}
}
if(text=="resetFolder"){
folder="";
}
if(text=="switch"){
folder=(String)"/"+addDir+String(key);
}
if(text=="goto"){
dir=dir+"/"+prev;
}
thingy=(String)text[0]+text[1]+text[2]+text[3];
if(thingy.equals("get:")){
convert(String(text[4]));
d=c;
convert(String(text[5]));
key=0;
while(keyc){
detectButtons();
}
}
thingy=(String)text[0];
if(thingy=="+"){
addDir=(String)text[1];
}
if(text=="name"){
filename=prev;
}
if(text=="appendTo"){
if(SD.exists("/USERS/"+dir+"/"+filename+".TXT")){
myFile=SD.open("/USERS/"+dir+"/"+filename+".TXT");
file="";
while(myFile.available()){
file=file+(char)myFile.read();
}
myFile.close();
SD.remove("/USERS/"+dir+"/"+filename+".TXT");
myFile=SD.open("/USERS/"+dir+"/"+filename+".TXT",FILE_WRITE);
myFile.print("~"+prev);
myFile.close();
}
}
if(text=="createFile"){
if(SD.exists("/USERS/"+dir+"/"+filename+".TXT")){
SD.remove("/USERS/"+dir+".TXT");
}
myFile=SD.open("/USERS/"+dir+"/"+filename+".TXT",FILE_WRITE);
myFile.print(prev);
myFile.close();
}
if(text=="enableTyping"){
value="";
lcd.clear();
lcd.setCursor(0,0);
lcd.print(prev);
lcd.setCursor(0,1);
while(key!=28 or keyShift==0){
key=0;
while(key==0){
detectButtons();
}
if(value.length()==20){
lcd.setCursor(0,2);
}
if(value.length()==40){
lcd.setCursor(0,3);
}
if(value.length()<60){
if(keyShift==1){
if(shifts[key]!='~'){
value=value+shifts[key-1];
lcd.print((String)value[value.length()-1]);
}
}else{
if(keyboard[key]!='~'){
value=value+keyboard[key-1];
lcd.print((String)value[value.length()-1]);
}
}
}
}
}
prev=value;
STEP=STEP+1;
}
delay(1000);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("You are logged out.");
delay(1000);
}
void printLCD(String text){
lcd.clear();
lcd.setCursor(0,0);
for(int i=0; i<text.length(); i++){
if(i%20==0){
lcd.setCursor(0,i/20);
}
lcd.print(text*);*

  • }*
    }
    void convert(String integer){
  • c=0;*
  • for(int b=0;b<integer.length();b++){*
    _ c=c10;_
    _ switch(integer**){_
    _
    case'1':_
    _
    c=c+1;_
    _
    break;_
    _
    case'2':_
    _
    c=c+2;_
    _
    break;_
    _
    case'3':_
    _
    c=c+3;_
    _
    break;_
    _
    case'4':_
    _
    c=c+4;_
    _
    break;_
    _
    case'5':_
    _
    c=c+5;_
    _
    break;_
    _
    case'6':_
    _
    c=c+6;_
    _
    break;_
    _
    case'7':_
    _
    c=c+7;_
    _
    break;_
    _
    case'8':_
    _
    c=c+8;_
    _
    break;_
    _
    case'9':_
    _
    c=c+9;_
    _
    break;_
    _
    case'A':_
    _
    c=c+10;_
    _
    break;_
    _
    case'B':_
    _
    c=c+11;_
    _
    break;_
    _
    case'C':_
    _
    c=c+12;_
    _
    break;_
    _
    case'D':_
    _
    c=c+13;_
    _
    break;_
    _
    case'E':_
    _
    c=c+14;_
    _
    break;_
    _
    case'F':_
    _
    c=c+15;_
    _
    break;_
    _
    case'G':_
    _
    c=c+16;_
    _
    break;_
    _
    case'H':_
    _
    c=c+17;_
    _
    break;_
    _
    case'I':_
    _
    c=c+18;_
    _
    break;_
    _
    case'J':_
    _
    c=c+19;_
    _
    break;_
    _
    case'k':_
    _
    c=c+20;_
    _
    break;_
    _
    }_
    _
    }_
    _
    }_
    void detectButtons(){
    _
    keys=0;_
    _
    keyShift=shift;_
    _
    shift=0;_
    _
    for(int i=0;i<7;i++){_
    _
    digitalWrite(10,LOW);**_
    __ shiftOut(8,9,MSBFIRST,shiftOutput);
    digitalWrite(10,HIGH);
    delayMicroseconds(10);
    if(digitalRead(22)){
    keys=i;
    }
    if(digitalRead(23)){
    keys=i+7;
    }
    if(digitalRead(24)){
    keys=i+14;
    }
    if(digitalRead(25)){
    keys=i+21;
    }
    }
    if(key==27){
    shift=1;
    }
    if(key==28){
    addon=28-addon;
    }
    key=keys+add;
    add=addon;
    addon=0;
    digitalWrite(10,LOW);
    shiftOut(8,9,MSBFIRST,255);
    digitalWrite(10,HIGH);
    delayMicroseconds(10);
    while(digitalRead(22) or digitalRead(23) or digitalRead(24) or digitalRead(25)){
    delayMicroseconds(10);
    }
    }*

    CIRCUIT DIAGRAM:
    Shift register outputs to row(8, 9, 10), receives input in column through pins 22, 23, 24, 25. SD card and LCD screen are connected to the pins in the code. (SPI communication pins on mega are 50-53)
    FILES ON SD CARD:
    Doesn't matter. Use the previous ones but my arduino still won't work...__

Please read your first post and notice how a moderator modified it using code tags.

Please apply this to reply #4.

OK, get with the program! :astonished:

You need to go and read the forum instructions so that you can go back and modify each of your posts that the moderator has not repaired already - using the "More -> Modify" option below the right hand corner of your post - to mark up your code as such using the "</>" icon in the posting window. Just highlight each section of code (or output) from the IDE and click the icon. In fact, the IDE has a "copy for forum" link to put these markings on for you so you then just paste it here in a posting window.

It is inappropriate to attach it as a ".ino" file. People can usually see the mistakes directly and do not want to have to actually load it in their own IDE. And that would also assume they are using a PC and have the IDE running on that PC.

But don't forget to use the "Auto-Format" (Ctrl-T) option first to make it easy to read. As you did not post it as "code", it is now quite garbled and is always more difficult to read.

Also tidy up your blank space. Use blank lines only between functional blocks.