Pages: [1]   Go Down
Author Topic: Use Serial Data to Write My Program  (Read 304 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 38
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I currently have successfully interfaced my Arduino with another Mcu which streams RS232 data in the following format:

e.g.

45.6723, 9.0876, 545.256<CR>

It comes in at a baud rate of 38400.

How do I use the second value "9.0876" in an "IF" or "While" >5 statement?
Logged

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

Quote
I currently have successfully interfaced my Arduino with another Mcu which streams RS232 data in the following format:
How are you collecting the data? If you are collecting the data properly, in a NULL terminated array of chars, you can use strtok() to get each comma-separated token. Then, you can use atof() to convert the token to a float, and use that in an if statement.
Logged

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

http://www.gammon.com.au/serial
Logged

Pages: [1]   Go Up
Jump to: