Wifi Sheild Arduino plus keypad

Good morning...

I am using Arduino mega, Arduino wifi shield and a keypad.

When I connect the keypad to Arduino, it function properly.

However, when I add the wifi shield, the middle column (2,5,8) does not give correct values.

I am getting (1,4,7) instead go (2,5,8)

I am using this connection diagram.

and I am using the same program in the link

How can I solve the problem.

Thanks

Connection diagram from the above link:

Please post a link to the specific Arduino wifi shield you’re using.

This is the shield I am using:

https://zeroohm.com/pages/search-results-page?q=arduino+wifi+shield+integrated+antenna

This one, correct?
https://zeroohm.com/products/arduino-wifi-shield-integrated-antenna?variant=3395384934430

yes

I changed pin 7 to pin 9, now it's working.

Now I want to Save some information to the SD memory.

When I download the ReadWrite file from the SD memory library, it's working properly.

Now, when I integrate the SD memory code, with the keypad and a barcode scanner code, the SD card does not get initialised. "Initializing SD card...initialization failed!
"

How to solve the problem ?

As you can see from the diagram on the Documentation page of the Arduino WiFi Shield:
https://store.arduino.cc/usa/arduino-wifi-shield

The SD card's SS pin is connected to pin 4 of your Arduino board. So try connecting the keypad to a pin other than pin 4 and update your code accordingly. You should also be sure your code uses SD.begin(4) to set pin 4 as the SD card SS pin. If that doesn't solve your problem then you probably need to provide some information on what sort of hardware you have connected for the barcode scanner part of the project.

You will also notice that pin 7 of your Arduino board is used for "handshake" with the shield, which is likely why the original problem was solved when you changed the keypad connection from pin 7 to pin 9.

This is what I did, changed the keypad pin from 4 to 15.

I added the following code in the setup

 while(!mySerial){ ; }
  delay(500);
  ///////////////////////////////SD_Memory
  
   Serial.print("Initializing SD card...");
   if (!SD.begin(4)) { Serial.println("initialization failed!"); return; }
      Serial.println("initialization done.");

This is a link to the barcode scanner that I used

http://playground.arduino.cc/ComponentLib/BarcodeScanner

and I added this code before the setup

#include <SPI.h>
#include <SD.h>

File myFile;

But the SD card did not initialised

So you have a configuration that works one that does not. There is something different between the two configurations that caused the breakage.

The key to troubleshooting is to rule out as many possible causes of that breakage as possible. Once you can determine the cause of the problem you're 90% of the way to fixing it.

You said:

FutureEngineer:
when I integrate the SD memory code, with the keypad and a barcode scanner code, the SD card does not get initialised.

So you made a bunch of changes all at once, thus you don't know which of those changes caused the breakage. This is why it's very important to do incremental development in small steps, testing after each one. It might seem slower at first but in the end it's much faster and less frustrating.

This is what I have in the setup

void setup(){
  
 
  ///////////////////     Barcode
 
  pinMode(dataPin, INPUT);                                               
  pinMode(clockPin, INPUT);                                              
  pinMode(ledPin, OUTPUT);  
  
  Serial.begin(115200); 
  mySerial.begin(9600); 
  while(!Serial){ ; }
  while(!mySerial){ ; }
  delay(500);

  ///////////////////////////////SD_Memory
  
   Serial.print("Initializing SD card...");
   if (!SD.begin(4)) { Serial.println("initialization failed!"); return; }
      Serial.println("initialization done.");
     
  ///////////////////////////////////
  
  mySerial.write("ScanBarcode:2222");
  mySerial.write(254); mySerial.write(192); 
  mySerial.write("orEnter5555:"); delay(2000); 
  
  ////////////////////////////

}

Now the SD card is initialised: "Initializing SD card...initialization done."

But when I add this line: myFile = SD.open("Test.txt", FILE_WRITE);

I get the initialisation error again !!

How to proceed!!