c++ - 433 Receiver Arduino if statement -
433 mhz receiver
arduino environment
the transmitter sends y, n or m works fine. problem lies in receivers code. goal is, after receiver has value message equal n, suppose trigger if statement thing. need have system can determine if receiver takes in specific value.
void loop() { if (vw_get_message(message, &messagelength)) // non-blocking { serial.print("received: "); (int = 0; < messagelength; i++) { serial.write(message[i]); const char *p = reinterpret_cast<const char*>(message); if(p == "n") { serial.print("if statement works when = n"); } } } }
the problem, not job, , after 2 weeks of struggle, @ loss. code compile , run, if statement ignored.
if (p=="n")
compares 2 pointers. while contents point can identical, not mean pointers equal.
you may want strcmp
(c style) or std::string::operator==
(canonical c++)
Comments
Post a Comment