Hi arduino gurus
I have ITEADUINO V2.1 WITH ATMEGA328 which same as the old Duemilanove. I also have the Atlas Scientific pH stamp. I would like to do a very simple project but since I am a complete noob, I will need help from you guys.
I would like to trigger some Leds and Buzzer when a certain range of pH is reached. I also want to display the pH on LCD
Here's my question:
1)Do i need to modify the code given by Atlas
http://atlas-scientific.com/_files/code/Arduino-sample-code-EZ-COM.pdf ??
2)I got this code from some one. Once i got the pH to float, I can display it on LCD......but the problem is got erros using this code. Here's the code
// -------------------------------------------------------------------------------
//
// Simple way to get Atlas Scientific serial PH stamp value to LCD or PC
// Author: Eric van Riet - The Netherlands
//
// ***************ONLY THE PART FOR PH IS LISTED!*****************
// ASSUMED THAT OTHER LIBRARIES FOR LCD ETC ARE IN YOUR OWN CODE!!
// -------------------------Set measurement interval------------------------------
long phReadInterval = 1000;
long previousMillisPH = 0;
int PHState = HIGH;
// -------------------------------------------------------------------------------
// ---------------Variable to hold PH value---------------------------------------
float PH_Val;
// -------------------------------------------------------------------------------
void setup()
{
Serial.begin(38400); // Set baudrate for hardware serial port 0 (PC)
Serial1.begin(38400); // Set baudrate serial port 1 to 38400 (PH)
lcd.begin (20,4); // initialize the lcd
// -------------Get PH value from Atlas Scientific PH serial stamp----------------
void getPHvalue() { //get PH every interval (1000 ms)
unsigned long currentMillisPH = millis();
if(currentMillisPH - previousMillisPH > phReadInterval) {
previousMillisPH = currentMillisPH;
if (PHState == HIGH) {
PHState = LOW;
}
else {
PHState = HIGH;
Serial1.print("r\r"); // 'R' reads one value, see stamp doc
while (Serial1.available() > 0) {
// Serial1.parseFloat looks for the next valid float number
// in the serial stream. In this case on hardware serial 1
PH_Val = Serial1.parseFloat();
// look for the carriage return. That's the end of your sentence:
if (Serial1.read() == '\r') {
Serial.println(PH_Val); // can be used for debug, pc display etc.
}
}
}
}
}
// -------------------------------------------------------------------------------
void loop()
{
getPHvalue();
lcd.setCursor(0,1);
lcd.print("PH value: ");
lcd.print(PH_Val);
}
and here's the error:
EZ_com.ino: In function 'void setup()':
EZ_com:22: error: 'Serial1' was not declared in this scope
EZ_com:23: error: 'lcd' was not declared in this scope
EZ_com:27: error: a function-definition is not allowed here before '{' token
EZ_com:61: error: expected `}' at end of input
why?????????????????
Moderator edit:
[code] [/code] tags added.