c++ - Arduino not taking multiple commands -


i'm trying basics done arduino, , i'm starting off small.

that said, want arduino listen simple, multiple commands being sent raspberry pi (i'm emulating through serial monitor now, however)

this code i'm working with:

#include "softwareserial.h"  void setup() {   serial.begin(9600);   delay(100); }  void loop() {     if (serial.find("test1")) {       delay(100);       serial.println("test1 command received");     }     if (serial.find("test2")) {       delay(100);       serial.println("test2 command received");     }   } } 

sadly, test1 command triggers serial print response, test2 no. can here point me in right direction?

thank you!

from reading documentation, don't think can use find() function that.

consider happens if test2 input, when find("test1") call running. consume characters , including 2, , return false, @ point characters lost.

i think should design actual protocol, delimiter between commands, , read/parse those.


Comments

Popular posts from this blog

unity3d - Rotate an object to face an opposite direction -

angular - Is it possible to get native element for formControl? -

javascript - Why jQuery Select box change event is now working? -