Open Tempy111 opened 4 years ago
Hi @Tempy111,
At first glance, you used the wrong kind of brackets for the char array. Try this:
char msg[MAX_PACKAGE_SIZE];
Also you cannot do a string comparison using the ==
operator in C++. At least not using char pointers. Try this:
if (strncmp(msg, "ArmUp", sizeof("ArmUp")) == 0){
...
}
Here is a reference for the strncmp()
function: http://www.cplusplus.com/reference/cstring/strncmp/
Alternatively you can try to convert the msg array into an object of the String
class: https://www.arduino.cc/reference/en/language/variables/data-types/stringobject/
// You always need to make sure that msg is 0-terminated
msg[MAX_PACKAGE_SIZE - 1] = 0;
String msg_copy(msg);
if (msg_copy == "ArmUp") {
...
}
Ah.. thanks.. my C++ is very rusty..
I'll have to test that more a bit later cause I just tried and I wasn't getting any signal transmitted.. so i'll have to check a bit later cause that's an unrelated issue that needs dealing with ^_^
all works now... but.. the servo keeps twitching.. not sure why.. not getting any message on the serial output, which I set up so that i'll get a message when a servo action is done... and there are no crossed wires... weird.. can't quite see how the RF transmitter is interfering like that..
I'm using a Sparkfun Pro Micro which uses a ATmega32U4 chip, Following the code in the example for the RF receiver and transmitter, I'm successfully transmitting but the receiver is just picking all the signal's as "T".
for transmitting the code I'm using is:
(the char msg line is slightly different from the example cause I was getting some warnings, but when I tried the original, it didn't make any visual difference apart from the warnings). I do a serial print line to check the msg value..
here is the full code (so far really.) for the receiver: