serial help?

just trying to figure out how to change a delay value via serial example

int incomingbyte;
void setup() {
Serial.begin(9600);
pinMode(7, OUTPUT);
digitalWrite(7, HIGH);
}
void loop() {

if (Serial.available() > 0) {
incomingbyte = Serial.read();
}
if(incomingbyte == 98){
digitalWrite(7, LOW);
delay(1000); // "How can I change the 1000 via serial?"
digitalWrite(7, HIGH);

}

}

Easiest way is to make the '1000' an integer variable, just like 'incomingbyte'. Then you can have one character, say '=', increment the variable and one character, say '-', decrement the variable.

Ive been all over the internet and cant find any good examples, mostly stuff like hello world or switches, I'm more lost now then ever.

Ive been all over the internet and cant find any good examples

You haven't told us what you are looking for, so we can't be much help.

Tell us what you want to send, and what you want to have happen when you send that.

Something like "Tuesday" should produce a 837 millisecond delay, and "fork" should produce sparks.

Or perhaps something logical in should produce some logical output. What is logical input for you, and what should the logical output be?

Well like Tuesday is 837 delay, Friday 427 I need to be able to change the delay numbers for Tuesday Friday ect.

if (Serial.available() > 0) { incomingbyte = Serial.read(); } if(incomingbyte == 98){ digitalWrite(7, LOW); delay(1000); // "How can I change the 1000 via serial?" digitalWrite(7, HIGH); }

putting if(incomingbyte == 98){ } outside of if (Serial.available() > 0) { } means that it will keep processing if(incomingbyte == 98){ } until incoming byte changes even if nothing is read in by next time loop() goes around

You need to spend more time considering input and possible errors as well as what you want to do with it.

delay(1000); // "How can I change the 1000 via serial?"

You already read a byte and checked that it matches a condition/value then why not change the delay? Hmmmm. Maybe set up a variable, modify that depending on serial input and use it inside delay()?

if(incomingbyte == 98){

Don't you think if(incomingbyte == 'b'){ is easier to read?

Well like Tuesday is 837 delay, Friday 427 I need to be able to change the delay numbers for Tuesday Friday ect.

OK. This is plain stupid. Just send the value that you want to delay. Learn to read serial data, collect the data into an array, and convert the array to a value that delay() can use.

http://jhaskellsblog.blogspot.com/2011/05/serial-comm-fundamentals-on-arduino.html

oh wow thanks its just what i need. I have a string of relay's that go off,ruining various pumps, got it all up and running, but it would be nice to be able to change the delay values without loading in a new schetch. Occasionally I have to plug in the laptop via usb, as part of the program uses my laptop keys "n and p" and each time I do the program resets, I'm going to have to cut the reset EN to fix that. That would be fine if the arduino wasn't berried in computer case behind hundreds of wires its very difficult to get to the reset switch to load in the new schetch. I even thought about moving on to a netduino they don't seem to have this problem. Not that good at programing but learning fast thanks for the help.

You might find a cheap digital display and a couple of buttons for + and -. If you don’t need to see a number then a turn pot would do for delay control.