Go Down

Topic: Use Serial Data to Write My Program (Read 341 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

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

Go Up