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");}
}