This is the updated code but my sketch stills stop/crashes in LOOP where i am trying to post again
My code is long so i have posted it in 2 replies
#include <Keypad.h> // Include the Keypad library.
#include <LiquidCrystal.h>
#include <SPI.h>
#include <Ethernet.h>
const byte rows = 4; // Define the amount of rows and columns for the keypad.
const byte cols = 4;
byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
char server[] = "beta1.tossdown.com";
//char server[] = "tossdown.com";
IPAddress ip(192, 168, 5, 34);
EthernetClient client;
LiquidCrystal lcd(A1,A0,A5,A4,A3,A2);
char keys[rows][cols] = { // Define the characters of the keypad.
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'}
};
byte rowPins[rows] = {9,8,7,6}; // Define the pins connected to the keypad.
//byte colPins[cols] = {5,4,3,2};
byte colPins[cols] = {5,3,2,1};
//byte colPins[cols] = {5,12,11,10};
Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, rows, cols); // Initialize the keypad.
void setup()
{
Serial.begin(9600);
Serial.println(F("in Setup"));
MainSet();
getNumber();
clientConnect();
}
void loop()
{
Serial.println(F("in Loop"));
MainSet();
getNumber();
clientConnect();
}
//---------------------------------
int i = 0;
char* ourCode = "13467913"; // Set the required PIN code.
char* ourCode1 = "********";
char key;
void MainSet()
{
i =0;
ourCode1[0] = '*';ourCode1[1] = '*';ourCode1[2] = '*';ourCode1[3] = '*';ourCode1[4] = '*';ourCode1[5] = '*';ourCode1[6] = '*';ourCode1[7] = '*';
lcd.begin(16, 2);
lcd.setCursor(0,0);
lcd.clear();
lcd.print(F("Enter Card #"));
}
void getNumber()
{
while(i!=8)
{
char key = keypad.getKey(); // Get the key press from the keypad.
//Serial.println(key);
if (int(key) !=0)
{
if(key == '0' || key == '1' || key == '2' || key == '3' || key == '4' || key == '5' || key == '6' || key == '7' || key == '8' || key == '9')
{
lcd.setCursor(i,1);
//lcd.print(ourCode1[i]);
ourCode1[i] = key;
lcd.print(ourCode1[i]);
i++;
}
else if (key == '*') // To clear Screen if wrong number/digit entered
{
i=0;
ourCode1[0] = '*';ourCode1[1] = '*';ourCode1[2] = '*';ourCode1[3] = '*';ourCode1[4] = '*';ourCode1[5] = '*';ourCode1[6] = '*';ourCode1[7] = '*';
lcd.clear();
MainSet();
}
else if (key == 'A' || key == 'B' || key == 'C' || key || 'D' || key == '#')
{
i=0;
ourCode1[0] = '*';ourCode1[1] = '*';ourCode1[2] = '*';ourCode1[3] = '*';ourCode1[4] = '*';ourCode1[5] = '*';ourCode1[6] = '*';ourCode1[7] = '*';
lcd.setCursor(0,2);
lcd.print(F("Invalid Input"));
delay(1000);
lcd.clear();
MainSet();
}
}
} i = 0;
}