Pages: 1 [2]   Go Down
Author Topic: Serial problem  (Read 841 times)
0 Members and 1 Guest are viewing this topic.
indonesia
Offline Offline
Newbie
*
Karma: 0
Posts: 33
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

@ 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 smiley
« Last Edit: November 29, 2012, 03:14:25 am by alva » Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 302
Posts: 26250
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

"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.

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 481
Posts: 18742
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged


New Jersey
Offline Offline
Faraday Member
**
Karma: 67
Posts: 3684
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 302
Posts: 26250
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

"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.

indonesia
Offline Offline
Newbie
*
Karma: 0
Posts: 33
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

hii....thanks for replying

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

Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 611
Posts: 49101
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Is there any other way to omit delay other than milis?
There's micros().
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 481
Posts: 18742
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

@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
Logged


Pages: 1 [2]   Go Up
Jump to: