Go Down

Topic: Serial problem (Read 955 times) previous topic - next topic

alva

#15
Nov 29, 2012, 08:51 am Last Edit: Nov 29, 2012, 09:14 am by alva Reason: 1
@ Wildbill:
Thanks for your explanation as it helps me out with my problem.
I still some other issues:
1. How would you get a newer version of IDE?
2. What is the maximum character I could send in 64 bytes read buffer?
3. If I throw out String, what is the substitute?
4. Considering question no.3, is there other way to solve my problem without re-writing the program? Can I limit the character of the data without rewriting the program?

@Nick Gammon:

Thank you for advice. However, if I don't use delay, based on your experience, what function should I use to hold the led to light for 5 second? if I use interupts timer,can i use 2 different timers in one arduino?

@others:

Is there any other comment? I do appreciate your participation :)

AWOL

Quote
However, if I don't use delay, based on your experience, what function should I use to hold the led to light for 5 second?

Have a look at the "blink without delay" example that came with the IDE for a clue.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Nick Gammon


2. What is the maximum character I could send in 64 bytes read buffer?


You don't send in a read buffer, however I think the answer would be 64.

wildbill

1. You can download the latest version from the main site if you don't already have it, but the issue isn't the IDE, your code needs to change.
2. 64. Tweak your input data to be less than 64 and reduce the number of commas that trigger printing and you should see something coming from the Arduino.
3. Null terminated arrays of char and the standard c functions that handle them with names that start with str, such as strcpy, strcat.
4. You can still use String, though it is ill advised because of the memory allocation bug that comes with it. But you need to get rid of delay as AWOL advised.

AWOL

Let me give you a really good reason not to use "delay()".
At 9600 bits per second, if you were executing a "delay (1000);", and the transmitter were sending continuously, you could overflow the receive buffer (and know nothing about it!) 15 times.
Sadly, you're not executing "delay (1000)", you're executing "delay (5000)".
That's 4800 characters lost.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

alva

hii....thanks for replying

Is there any other way to omit delay other than milis?


PaulS

Quote
Is there any other way to omit delay other than milis?

There's micros().

Nick Gammon


@Nick Gammon:

Thank you for advice. However, if I don't use delay, based on your experience, what function should I use to hold the led to light for 5 second?


http://www.gammon.com.au/blink

Go Up