AWOL:
Is there anything else that needs to be changed in the code?
You haven't posted any, so how can we tell?
I'm sorry AWOL. As suggested by PeterH, I've changed some of the code and below there's my code. Every function returns ONE single "value" and break from its case. I need that one function (in this case "Pres()") continues to keep the routine (to return the value everytime) untill the User give it a break (for example) pressing a key on the keyboard.
//includes necessary libraries
#include <......>
//Some setup & variables/constants declaration & other stuff
char ch=0; //global variable for Serial.read()
void setup() {
Serial.begin(9600);
//arduino/sensor setup and other stuff
}
void loop(){
if(Serial.available()){
delay(100);
ch=Serial.read();
switch(ch)
{
case '1':
SHT1();
break;
case '2':
SHT2();
break;
case '3':
Pres();
break;
case '4':
LIGHT1();
break;
case '5':
LIGHT2();
break;
default:
Serial.print(ch);
Serial.println(" unknown command");
}
}
}
void SHT1(){
// do measurement and return ONE DATA
}
void SHT2(){
// do measurement and return ONE DATA
}
void Pres(){
// do measurementS and RETURN DATA AS LONG AS USER PRESS ONE KEY TO STOP MEASUREMENT
}
void LIGHT1() {
// do measurement and return ONE DATA
}
void LIGHT2() {
// do measurement and return ONE DATA
}