string phrase recognition

Hi Folks!
I am attempting to send a phrase via an HC12 transceiver connected to a Nano to another HC12 and Nano combination. Sending and receiving the data between the two works. However, I am unable to get the comparison of the received data to equal the desired phrase at the receiver end. I have attached the code for both the sender and the receiver. Below is a snippet from the monitor at the receiver end. Apparently I am trying to compare apples and oranges. Can someone please tell me how to get the data to be apples only so I can compare them? Thanks.

Monitor output
###########################################################################

HC-12 Ratio Test
Sends sequential number
1
red_line
2
yellow_line
3
1
red_line
2
yellow_line
3
1
red_line
2
yellow_line
3
1
red_line
2
yellow_line
3
1
red_line

HC12_Send_jan30a.ino (889 Bytes)

HC12_Rec_jan30a.ino (1.76 KB)

If you post your code in code tags more members will see it.

I might have helped if the code had been properly posted. As it stands now, my mobile device does not let me view .ino files. Someone with 42 posts should have read the locked posts at the top of this forum to learn how to use code tags.

I am out of here.

To put your code in a code box, use the </> icon in the far left of the post tool bar and paste your code between the two bracket sets that appear.

To go back and put your code in a code box, in the bottom right of your post, select “more” and click modify. When the modify post opens, high light your code and click the </> in the far left of the post tool bar. This will put you code in code brackets. Then save the changes.

    if (receivedChars == "red_line")

C style strings cannot be compared with string literals like this

Take a look at the strcmp() function

Hi Folks! Thanks for the replies. The strcmp() function solved my problem. Anyone care to explain how this works? Thanks. Brian

Anyone care to explain how this works?

Explain what exactly ?

The strcmp() function is for comparing strings. That's all there is to it. If you want to know how/why your revised code works then you need to post it

kingbf: Anyone care to explain how this works? Thanks.

https://code.woboq.org/userspace/glibc/string/strcmp.c.html