Hello everyone. I have a Arduino Uno board that sends a message 10 times via virtualwire [433mhz transreceiver] to my nano board wich of course has the matching receiver, once a button is pushed..
byte count = 0;
char msg[8] = { 'k','l','i','n','g','e','l','#' };
void loop()
{
if (count == 0 && digitalRead(3) == LOW)
{
count = 10;
}
else if (count > 0)
{
digitalWrite(1, HIGH);
vw_send((uint8_t *)msg, 8);
vw_wait_tx();
digitalWrite(0, LOW);
count = count - 1;
}
else
{
digitalWrite(1, LOW);
}
}
My problem is the receiver side. i want to pack the received information into a char array and then compare it to another char array that of course hase the same message as the transreceiver has sent to see if it matches. If it matches it should just set a flag so i can it blocks the the incoming messages until it has done a certain action in wich it also resets that received information.
Currently i get my status of those two char arrays displayed, the receiving one is of course empty and the fixed one for comparsion has the information "klingel#".
But once i send my message over to the board the receiving array gets "lingel##" and the comparing one gets "klingel##" It seems to take one byte out and just fill it with #
The doubled Serial output of those two arrays will be removed later. I just added it to locate the issue
Thanks in advance for your help, here is the loop part of my receiver
byte count = 0;
char msg[] = ""; //Speicher für die eingehende Nachricht
char comp[9] = "klingel#"; // Vergleich für die eingehende Nachricht
void loop()
{
uint8_t buf[VW_MAX_MESSAGE_LEN];
uint8_t buflen = VW_MAX_MESSAGE_LEN;
Serial.println(msg);
Serial.println(comp);
if (vw_get_message(buf, &buflen)) // Non-blocking
{
Serial.print("Aktueller Zustand des Flags lautet: ");
Serial.println(flag);
int i; // Zähler für den Array pointer
digitalWrite(led_pin, HIGH); // Empfange Nachricht [LED AN]
for (i = 0; i < buflen; i++)
{
msg[i] = buf[i];
}
Serial.print(" MSG lautet: ");
Serial.println(msg);
Serial.print(" COMP lautet: ");
Serial.println(comp);
}
if (msg == comp)
{
flag = 1;
char msg[8] = "";
}
}