Inputting data with LCD-Keypad module

Sorry if this is really simple, I am completely new to both programming & electronics.
I have a ekitszone LCD-Keypad module.
I have written a simple TimeLapse/Star Trails sketch to control my Nikon DSLR via IR

The sketch works fine, but I would like to be able to control the settings using the keypad
The code that comes with the LCD is

int adc_key_val[5] ={30, 150, 360, 535, 760 };
int NUM_KEYS = 5;
int adc_key_in;
int key=-1;
int oldkey=-1;

But I would like to bea bale to change number of exposures, shutter speed & delay time between shots

The code I have that works if I change on computer then upload to board is:

/*
 * Star Trails
 * 2011 Carassius Productions
*/

#include <LCD4Bit_mod.h>
#include <nikonIrControl.h>

LCD4Bit_mod lcd = LCD4Bit_mod(2);      // 2 line LCD on the LCD/Keypad shield
int CAM_IR_OUTPUT = 13;                // IR LED connected to pin 13

/* 
 *USER INPUT CHANGES BELOW
 *
 **********************************************
 *****CHANGE BELOW FOR NUMBER OF EXPOSURES*****
 **********************************************/
int numOfShotsRequired = 100;      // Sets number of exposures 

/**********************************************
 *****CHANGE BELOW FOR LENGTH OF EXPOSURES*****
 **********************************************/
int exposureTime = 10;      // Sets length of exposure in seconds

/**********************************************
 **********CHANGE BELOW FOR WRITE TIME*********
 **********************************************/    
int timeDelay = 10;      // Sets SD write time or Time Lapse Delay in seconds



int currentShot = 0;
char lcdString[4];

void setup() {                
  // initialize the IR LED
  pinMode(CAM_IR_OUTPUT, OUTPUT);    
 
   //initialise the LCD
  lcd.init();
  lcd.clear();
  lcd.commandWrite(0x0C);              // No cursor

  //display the startup splash screen
  lcd.cursorTo(1,0);
  lcd.printIn("Carassius Pro   ");
  lcd.cursorTo(2,0);
  lcd.printIn("Star Trails   "); 
  delay(3000);                         // Show splash screen for 3 seconds
  lcd.clear();
}

void loop() {

while(currentShot <= numOfShotsRequired - 1)
  {
    currentShot = currentShot + 1;
         lcd.clear();
    lcd.cursorTo(1,0);
    lcd.printIn("Photo ");
   itoa(currentShot,lcdString,10);
    lcd.printIn(lcdString);
    lcd.printIn(" of ");
  itoa(numOfShotsRequired,lcdString,10);
    lcd.printIn(lcdString);
    delay(86);    // sleep for 1/10th of a second
     // On  
  lcd.cursorTo(1,0);
  lcd.printIn("   ");
  lcd.cursorTo(2,0);
  lcd.printIn("EXPOSING");
     cameraSnap(CAM_IR_OUTPUT);     // start exposure

     delay(exposureTime * 1000); // sets exposure time (1 sec = 1000)
                                                    
   // Off
lcd.clear();
  lcd.cursorTo(1,0);
  lcd.printIn("   ");
  lcd.cursorTo(2,0);
  lcd.printIn("SAVING");
     cameraSnap(CAM_IR_OUTPUT);     // end exposure     
 
     delay(timeDelay * 1000);// save time to memory (1 sec = 1000)
  }
  lcd.clear();
  lcd.cursorTo(1,0);
  lcd.printIn("*** COMPLETED *** ");
}

I have tried to add the following with no luck

//Delay & Write Time
int timeDelay[7]={5,10,20,30,60,120,300};
char timeDelay[7][17] ={"5 sec ","10 sec ","20 sec ","30 sec ","1 min ","2 min ","5 min "};

//Shutter Speed  
int exposureTime[14]={1,2,4,8,16,32,60,120,300,600,900,1200,1800,3600};
char exposureTimeText[14][7] ={"1 sec ","2 sec ","4 sec ","8 sec ","16 sec","32 sec","1 min","2 min ","5 min ","10 min","15 min","20 min","30 min","1 hr"};

//Number of photos selection
int numOfShotsRequired = 7;

Any help would be fantastic
Cheers
Jon

I have tried to add the following with no luck

Complaining "that didn't work", without explaining what you expected to have happen vs. what actually did happen, might make you feel better, but it does absolutely nothing towards getting you help.

Would you care to elaborate?

Ok, I am not a programmer so please forgive me for explaining in laymans terms

The LCD Keypad has 5 buttons, In my code I have the following settings I input data into

int numOfShotsRequired = 100;      // Sets number of exposures 
int exposureTime = 10;      // Sets length of exposure in seconds 
int timeDelay = 10;      // Sets SD write time or Time Lapse Delay in seconds

i would like Up or down to scroll through the different options (exposures, shutter, delay) & left or right to change the settings

So by scrolling up or down brings you to the next setting, for delay & shutter speed, I want predefined settings, and for exposures, I want to be able to increase & decrease by 1, that's where I came up with this code

//Delay & Write Time
int timeDelay[7]={5,10,20,30,60,120,300};
char timeDelay[7][17] ={"5 sec ","10 sec ","20 sec ","30 sec ","1 min ","2 min ","5 min "};

//Shutter Speed  
int exposureTime[14]={1,2,4,8,16,32,60,120,300,600,900,1200,1800,3600};
char exposureTimeText[14][7] ={"1 sec ","2 sec ","4 sec ","8 sec ","16 sec","32 sec","1 min","2 min ","5 min ","10 min","15 min","20 min","30 min","1 hr"};

//Number of photos selection
int numOfShotsRequired = 7;

I hope that helps, I thank you for looking at this for me and hope it explains what I am trying to achieve

Cheers
Jon

that's where I came up with this code

OK.

hope it explains what I am trying to achieve

It was clear what you were trying to achieve. What isn't clear, still, is what problem you are having.

The problem I am having is I don't know what I am doing so it doesn't compile, I am missing something in my code that converts keypresses into text, stores the data and inputs the relevant data.

I just don't know what commands are required for keypad input, nor have my searches been able to give me any answers that I have been able to decipher.

Sorry, as said, I am completely new to programming and am completely stumped by this :blush:. The code is the first coding I have done (besides VB in Excel) since a kid playing on my commodore 64 :roll_eyes:

I am missing something in my code that converts keypresses into text

You need to define that mapping. With only 5 switches, you are limited to 5 characters, so that should be pretty easy.

char letters[5] = {'x', 'y', 'b', 'f', 'g'}; // Or whatever letters the switches are to correspond to.

Each switch corresponds to one element in that array.

stores the data

Again, you need an array and an index into that array.

char userInput[20]; // Or however many characters you want the user to input
byte userIndex = 0; // Location to store the next character

Each time a switch is pressed, find the corresponding letter in the letters array, and add it to the userInput array, at the userInput position, and then increment userInput.

and inputs the relevant data.

Inputs it? Seems like at some point you want to output or use whatever it is the user pushed the switches to define.

I just don't know what commands are required for keypad input

Without seeing a link to the keypad that you have, I'd say that there are two possibilities. The first possibility is that the switches use a resistor ladder and are all connected to an analog pin, in which case you use analogRead() on that pin, and a series of if statements to determine which switch was pressed based on the value analogRead returns.

The second possibility is that the switches are attached to 5 different digital pins, and you use digitalRead() to poll each pin. The one that returns HIGH (or LOW depending on how they are wired - the different value, anyway) is the one that was pressed.

The problem I am having is I don't know what I am doing so it doesn't compile

Well, the compiler is trying to tell you exactly what is wrong. Sometimes the messages may not appear to be anything other than foreign language gibberish, but often the message is perfectly clear (at least ofter you've seen it 1000 times). Fixing the problem is often a completely different story.

Post the code you have, and the error messages, and we'll help you figure out what they mean, and how to fix them.