Pages: [1]   Go Down
Author Topic: Use Serial Data to Write My Program  (Read 336 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: 650
Posts: 50838
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
Melbourne, Australia
Offline Offline
Brattain Member
*****
Karma: 510
Posts: 19306
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

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

Please post technical questions on the forum - not to me by personal message. Thanks a lot.

Pages: [1]   Go Up
Jump to: