Go Down

Topic: Use Serial Data to Write My Program (Read 366 times) previous topic - next topic

chiques

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?

PaulS

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.

Nick Gammon

Please post technical questions on the forum, not by personal message. Thanks!

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

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy