Science lab data collection.

Hi all,
I'm trying to clone an instrument that our university uses in it's chem labs.
I'm using the sensors from the instruments and want to replace everything else.
The sensor info can be seen here.
http://www.vernier.com/tech/manuals.html
I'm working with the SS temp probes right now and have them working.
(I can post my sketch if anyone is interested.)

The rest of the project is using the keypad from sparkfun.

The lcd from modern device.
http://shop.moderndevice.com/products/lcd117-kit
And the logshield from adafruit.
http://www.ladyada.net/make/logshield/
I also have a Duemilanove w/328 and a Mega.

My problem now is trying to figure out the simple(?) stuff of reading the keypad and getting some numbers to work with.
What I think I want it to do is ask for the number of samples to collect, and how long to wait between each sample. Eventually I want to store the data on a logshield so the SD card can be read on a computer and the data analyzed.
I'm not sure how to make the program wait for the input and then add multiple inputs together.
What I have so far.

/*
* Arduino 0022
* Using a Duemilanove w/328.
* Program to test adding multiple entries from the keypad.
* Uses the 12 button keypad from Sparkfun.
* Uses a serial display from Modern Devices.
* Will use a log shield from adafruit.  Has SD card and RTC on one card.
*/
#include <SoftwareSerial.h>
#include <Keypad.h>

//**************************************************************************************************
//Software Serial setup
#define rxPin 4  // rxPin is immaterial - not used - just make this an unused Arduino pin number
#define txPin 14 // pin 14 is analog pin 0, on a BBB just use a servo cable :), see Reference pinMode
SoftwareSerial mySerial =  SoftwareSerial(rxPin, txPin);
// mySerial is connected to the TX pin so mySerial.print commands are used
// one could just as well use the software mySerial library to communicate on another pin


//*************************************************************************************************
//Keypad setup
const byte ROWS = 4; //four rows
const byte COLS = 3; //three columns
char keys[ROWS][COLS] = {
  {'1','2','3'},
  {'4','5','6'},
  {'7','8','9'},
  {'*','0','#'}
};
byte rowPins[ROWS] = {11, 10, 9, 8}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {7, 6, 5}; //connect to the column pinouts of the keypad

Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

int SampleTotalIn;   // Number of samples to collect. 
int SampleTimeIn;    // Time between samples.

char key;
char TestKey;
char Time1[5];
char Time2;
boolean SampleTotal = false;


void setup(){
   mySerial.begin(9600);
   pinMode(txPin, OUTPUT);
  
   mySerial.print("?G420");   // set display geometry,  4 x 20 characters in this case
   delay(500);                // pause to allow LCD EEPROM to program

   mySerial.print("?Bff");    // set backlight to ff hex, maximum brightness
   delay(1000);                // pause to allow LCD EEPROM to program

   mySerial.print("?s6");     // set tabs to six spaces
   delay(1000);               // pause to allow LCD EEPROM to program
   
   mySerial.print("?D0040A040000000000");       // define special characters
   delay(300);                                  // delay to allow write to EEPROM
                                                // see moderndevice.com for a handy custom char generator (software app)
   mySerial.print("?f");                   // clear the LCD
   delay(10);                                              
     
}

void loop(){
  /*
  * Set Boolean varible to false, we haven't run this yet.
  * Get the number of samples. Wait for a key press. (Convert the input to a number??)
  * Test for # to signal that the sample number is in.
  * After # set Bool varible to true, we have run this portion and go to Time between samples.
  */
  
  if (SampleTotal == false);
    mySerial.print("?x00?y0" "Samples");
    //wait for an input, when # goto next part.
      do
        {
          key = keypad.getKey();      
        }
      while(key != NO_KEY);             //I think this means get the key as long as no key was pressed.
  
  mySerial.print("?f"); 
  mySerial.print("?x00?y1"); 
  mySerial.print(key); 
  
  SampleTotal = true;       //set boolean var to true don't run this section againg.
   mySerial.print("?f");      // just clears the screen.
    

  //if (key != NO_KEY){
    //mySerial.print("?x00?y0"); 
    //mySerial.print(key);
    //Time1 += key;
    //TestKey = key;
     // }
      
    //mySerial.print("?x00?y1"); 
    //mySerial.print(Time2);
    //mySerial.print("?x03?y1"); 
    //mySerial.print(TestKey);
    
    //if (TestKey == '#'){mySerial.print("?f");} 
  
}

Why not start with the simplest example you can find...

http://arduino.cc/playground/Code/Keypad

Yeah, been there, understand that part.

Downloaded the Arduino Cookbook and found some help there.
This needs a little clean up I think.

/*
* Arduino 0022
* Using a Duemilanove w/328.
* Program to test adding multiple entries from the keypad.
* Uses the 12 button keypad from Sparkfun.
* Uses a serial display from Modern Devices.
* Will use a log shield from adafruit.  Has SD card and RTC on one card.
*/
#include <SoftwareSerial.h>
#include <Keypad.h>

//**************************************************************************************************
//Software Serial setup
#define rxPin 4  // rxPin is immaterial - not used - just make this an unused Arduino pin number
#define txPin 14 // pin 14 is analog pin 0, on a BBB just use a servo cable :), see Reference pinMode
SoftwareSerial mySerial =  SoftwareSerial(rxPin, txPin);
// mySerial is connected to the TX pin so mySerial.print commands are used
// one could just as well use the software mySerial library to communicate on another pin


//*************************************************************************************************
//Keypad setup
const byte ROWS = 4; //four rows
const byte COLS = 3; //three columns
char keys[ROWS][COLS] = {
  {'1','2','3'},
  {'4','5','6'},
  {'7','8','9'},
  {'*','0','#'}
};
byte rowPins[ROWS] = {11, 10, 9, 8}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {7, 6, 5}; //connect to the column pinouts of the keypad

Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

int SampleTotalIn;   // Number of samples to collect. 
int SampleTimeIn;    // Time between samples.

char key;
char sampleKey[6];
int index = 0;

char TestKey = 0;
char Time1[5];
char Time2;
boolean Sample = false;


void setup(){
   mySerial.begin(9600);
   pinMode(txPin, OUTPUT);
  
   mySerial.print("?G216");   // set display geometry,  4 x 20 characters in this case
   delay(500);                // pause to allow LCD EEPROM to program

   mySerial.print("?Bff");    // set backlight to ff hex, maximum brightness
   delay(1000);                // pause to allow LCD EEPROM to program

   mySerial.print("?s6");     // set tabs to six spaces
   delay(1000);               // pause to allow LCD EEPROM to program
   
   mySerial.print("?D0040A040000000000");       // define special characters
   delay(300);                                  // delay to allow write to EEPROM
                                                // see moderndevice.com for a handy custom char generator (software app)
   mySerial.print("?f");                   // clear the LCD
   delay(10);                                              
     
}

void loop(){
  /*
  * Set Boolean varible to false, we haven't run this yet.
  * Get the number of samples. Wait for a key press. (Convert the input to a number??)
  * Test for # to signal that the sample number is in.
  * After # set Bool varible to true, we have run this portion and go to Time between samples.
  */
     
  while (Sample == false)    // set the condition that runs this block of code
      {
        mySerial.print("?x00?y0" "Samples");  // cursor to first character of line 0 
        char key = keypad.getKey();
          if (index < 5)
          {
            if (key != NO_KEY)
              {
                mySerial.print("?x00?y1");  // cursor to first character of line 1
                mySerial.println(key);      // prints what key was pressed 
                sampleKey[index++] = key;   // increments the index for the string
                mySerial.print("?x05?y1");  // sets cursor position.
                mySerial.println(index);    // prints what position we are in the string
                mySerial.print("?x10?y1");  // set the cursor position
                mySerial.print(sampleKey);  // prints what's in the string
              }
          }
        TestKey = key;
        if (TestKey == '#')                 // using this as a return/done key
         {
           SampleTotalIn = atoi(sampleKey); // changes the string into a int
           mySerial.print("?f");
           Sample = true;                   // says were done with this block of code
         }

     }
   
   
   
   mySerial.print("?x00?y0" "Time");
   mySerial.print("?x10?y0");
   mySerial.print(SampleTotalIn);           // this is the number of samples to collect.

Can someone tell me if all I have to do is put this in setup for it to work?? keypad.setDebounceTime(100);

updated code

/*************************************************************************************************
* Arduino 0022
* Using a Duemilanove w/328.
* Program to test adding multiple entries from the keypad.
* Uses the 12 button keypad from Sparkfun.
* Uses a serial display from Modern Devices.
* Will use a log shield from adafruit.  Has SD card and RTC on one card.
**************************************************************************************************/
#include <SoftwareSerial.h>
#include <Keypad.h>

//**************************************************************************************************
//Software Serial setup
#define rxPin 4  // rxPin is immaterial - not used - just make this an unused Arduino pin number
#define txPin 14 // pin 14 is analog pin 0, on a BBB just use a servo cable :), see Reference pinMode
SoftwareSerial mySerial =  SoftwareSerial(rxPin, txPin);
// mySerial is connected to the TX pin so mySerial.print commands are used
// one could just as well use the software mySerial library to communicate on another pin


//*************************************************************************************************
//Keypad setup
const byte ROWS = 4; //four rows
const byte COLS = 3; //three columns
char keys[ROWS][COLS] = {
  {'1','2','3'},
  {'4','5','6'},
  {'7','8','9'},
  {'*','0','#'}
};
byte rowPins[ROWS] = {11, 10, 9, 8}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {7, 6, 5}; //connect to the column pinouts of the keypad

Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
/*******************************************************************************************************
* Varibles for the key pad
*******************************************************************************************************/
char key;
char nul = ' ';          // This clears what was in the sampleKey when * is pressed.
int index = 0;
char TestKey = 0;
boolean Sample = false;
char sampleKey[6];       // character array to hold keystrokes until conversion
int SampleTotalIn;       // Number of samples to collect. 
boolean Time = false;
char timeKey[6];         // character array to keystrokes until conversion
int SampleTimeIn;        // Time between samples.

void setup(){
   mySerial.begin(9600);
   pinMode(txPin, OUTPUT);
   
   keypad.setDebounceTime(100);
  
   mySerial.print("?G420");   // set display geometry,  4 x 20 characters in this case
   delay(500);                // pause to allow LCD EEPROM to program

   mySerial.print("?Bff");    // set backlight to ff hex, maximum brightness
   delay(1000);                // pause to allow LCD EEPROM to program

   mySerial.print("?s6");     // set tabs to six spaces
   delay(1000);               // pause to allow LCD EEPROM to program
   
   mySerial.print("?D0040A040000000000");       // define special characters
   delay(300);                                  // delay to allow write to EEPROM
                                                // see moderndevice.com for a handy custom char generator (software app)
   mySerial.print("?f");                   // clear the LCD
   delay(10);                                              
     
}

void loop(){
  /*
  * Set Boolean varible to false, we haven't run this yet.
  * Get the number of samples. Wait for a key press. (Convert the input to a number??)
  * Test for # to signal that the sample number is in.
  * After # set Bool varible to true, we have run this portion and go to Time between samples.
  */

/*******************************************************************************************************************************************
*  Code block to set the number of samples and time interval between the sample.
*
*******************************************************************************************************************************************/

  while (Sample == false)    // set the condition that runs this block of code
      {
        mySerial.print("?x00?y0" "Number of samples");  // cursor to first character of line 0 
        char key = keypad.getKey();
        mySerial.print("?x00?y1");  // cursor to first character of line 1
        mySerial.print(sampleKey);  // prints what's in the string
         if (index < 5)
          {
            if (key != NO_KEY)
              {
               if (key >= '0' && key <= '9') // Checks for just the numbers, don't store the * or # in the string.
                { 
                  sampleKey[index++] = key;   // adds the input to the string, increments the index for the string
                }
                mySerial.print("?x00?y1");  // cursor to first character of line 1
                mySerial.print(sampleKey);  // prints what's in the string
              }
          }
        TestKey = key;
        if (TestKey == '*')            //This clears the last entry.
          {
            index = index - 1;
            if (index < 0)
              {index = 0;}
            sampleKey[index] = nul;  
            mySerial.print("?b");     // clear cursor line
                       
          }  
        if (TestKey == '#')                 // using this as a return/done key
         {
           SampleTotalIn = atoi(sampleKey); // changes the string into a int
           mySerial.print("?f");
           Sample = true;                   // says we're done with this block of code
           index = 0;
         }

     }
   
   
  while (Time == false)    // set the condition that runs this block of code
      {
        mySerial.print("?x00?y0" "Time between samplesin seconds");  // cursor to first character of line 0 
        char key = keypad.getKey();
          if (index < 5)
          {
            if (key != NO_KEY)
              {
                mySerial.print("?x00?y2");  // cursor to first character of line 1
                //mySerial.println(key);      // prints what key was pressed
               
               if (key >= '0' && key <= '9') // Checks for just the numbers, don't store the * or # in the string.
                { 
                  timeKey[index++] = key;   // adds the input to the string, increments the index for the string
                }
                mySerial.print(timeKey);  // prints what's in the string
              }
          }
        TestKey = key;
        if (TestKey == '*')            //This clears the entries to start over.
          {
            index = index - 1;
            if (index < 0)
              {index = 0;}
            sampleKey[index] = nul;  
            mySerial.print("?l");     // clear cursor line
          }  
        if (TestKey == '#')                 // using this as a return/done key
         {
           SampleTimeIn = atoi(timeKey); // changes the string into a int
           mySerial.print("?f");
           Time = true;                   // says we're done with this block of code
         }

     }   
   mySerial.print("?x00?y0" "Samples");
   mySerial.print("?x08?y0");
   mySerial.print(SampleTotalIn);           // this is the number of samples to collect.
   mySerial.print("?x00?y1" "Time");
   mySerial.print("?x08?y1");
   mySerial.print(SampleTimeIn);
   mySerial.print(" Sec");
   
   
}

Shake hands with you. I'm a physicist and I want to do the same! Kudos to you trying to do something yourself while lots and lots of others buy teaching equipment off big-brand-name shelves for high prices.

In my case I'm fighting Pasco, and Vernier :slight_smile: I use photo gates etc.

Don't mean to advertise but I already have an extensive system that you can use to set up menus and asks users for all kinds of inputs, numbers, choose from a list, dates, texts (for filename?)

It makes things much easier. With just a few buttons you can enter anything, just one function call away. Use the functions whenever you want user inputs and then once you get the input, do your own stuff, such as sensing probes and storing them.

Here is a teaser. The formal release is set for Wednesday with my Phi-2 shield:

Blog page: