Pages: [1]   Go Down
Author Topic: Virtual wire help  (Read 299 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 14
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I am using sparkfuns transmitters and receivers and using the virtual wire library so my two arduinos can communicate. But I am having trouble with the code... How do you write something like "When you see this string-do this"? I have 14 commands I need to send ( 14 different things the receiving arduino will do when it gets one of the 14 messages from the sending arduino ). How would one go about doing this? As you have guessed I am pretty new to this whole thing and any help is greatly appreciated, but please try to keep the lingo to beginner levels.

Thanks in advance!
Logged

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

Quote
How do you write something like "When you see this string-do this"?
The VirtualWire class has a receive event handler. In that handler, you read the whole message.

Then, use strcmp() to compare the message to known messages, and do something when a match occurs.

If the messages contain data, too, strtok() can be used to parse the message.
Logged

Pages: [1]   Go Up
Jump to: