First, thanks to all you guys that post to the forum regularly, as I have spent days reading that stuff, and it is so helpful.
I am just getting back into programming, so I am a little rusty and need some help with serial communications. I have got the bulk of my code working for the operation, but am having a devil of a time getting the user interface portion to function the way I want.
Objective:
Use the setup() section to ask the user questions (via serial monitor) and take those responses in as variables. I have successfully been able to enter data on the serial monitor, move it from the serial buffer to a character buffer and convert to my desired data and store. Where I am having trouble, is doing this for different variables, only once, and not continually looping.
Example: (as viewed from the monitor)
How many break points do you want?
6 (user entered 6 and pressed enter)
Enter break point time 0:
0 (user entered 0 and pressed enter)
Enter break point time 1:
115 (user entered 115 and pressed enter)
.
.
.
Enter break point time 5:
10000 (user entered 10000 and pressed enter)
Would you like to run the operation now? (Y/N)
Y (user entered Y and pressed enter)
**program now runs contents in void loop()
I toyed with putting empty while looks after each question until the answer has been entered, but can't get that to work either.
Surely I am not the first person to try this, and I am hoping someone can save me some dev time and point me towards an example?
Code below is highly truncated, and does not even come close to what I am looking for, but every time I read a noob post, they get yelled at for not posting their code, so here it is.
/* Reflow Controller User Interface
wdenny
2012.05.31_r1
*/int b_points = 0;
String readString;
float test;
boolean stringComplete = false;void setup() {
Serial.begin(9600);
Serial.println("Reflow Controller User Interface"); // identify begining of programing and help with debugging
Serial.println("2012.05.31_r1");
Serial.println(" ");
Serial.println("How many break points? (integer values)");}
void loop(){
// print the string when a newline arrives:
if (stringComplete) {
Serial.println(readString);
// clear the string:
readString = "";
stringComplete = false;
}
}void serialEvent(){
while (Serial.available()) {
delay(10);
if (Serial.available() >0) {
char c = Serial.read();
readString += c;
}}
// char buf[readString.length()+1];
// readString.toCharArray(buf,readString.length()+1);
// test = atof(buf);
stringComplete = true;}