RF ASK issues

I am trying to control a set of LEDs with two Arduino Unos using a 433MHz transmitter/receiver.
I am able to send signals from the transmitter and receive them and see them trough the Serial monitor, but I cant get the receiver arduino to output to the LEDs.
Im not sure where the issue is.

When ever I press the 2nd button, which should send '2' I get this on the serial monitor.
"
16:38:09.195 -> 7777Got:
16:38:09.195 -> 7 7 7 7

16:38:12.291 -> 000647777Got:
16:38:12.327 -> 0 0 0 6 4 7 7 7 7

16:38:14.261 -> 333333647777Got:
16:38:14.261 -> 21 21 21 6 4 7 7 7 7

16:38:19.210 -> 000647700Got:
16:38:19.210 -> 0 0 0 6 4 7 7 0 0

16:38:23.863 -> 00647770Got:
16:38:23.863 -> 0 0 6 4 7 7 7 0

16:38:26.955 -> 333333647777Got:
16:38:26.988 -> 21 21 21 6 4 7 7 7 7

16:38:32.324 -> 333333647777Got:
16:38:32.358 -> 21 21 21 6 4 7 7 7 7 "
Each was a separate button press.

I have attached the code for both transmitter and receiver.

Any help is greatly appreciated.

receiver2.ino (4.66 KB)

transmitter2.ino (6.43 KB)

const char *msg2 = '2';
. . .
. . .

if (but2old==0 && but2new ==1)
{
   driver.send((uint8_t *)msg2, strlen(msg2));
    driver.waitPacketSent();
    delay(200);    
}

Can you give a link to where you got this code sample ?
I suspect that part of the problem is here: strlen(msg2) where you are sending the length of a pointer instead of the length of the string. Try strlen(*msg2).

The function driver.printBuffer() appears to print the hex values of the decimal numbers. 33 == 0x21

16:38:14.261 -> 333333647777Got:
16:38:14.261 -> 21 21 21 6 4 7 7 7 7

Maybe you could also look at using arrays to reduce code duplication.

strlen() only works with null terminated strings. 'msg2' is not null terminated.

Ah yes, I must have assumed the original code compiled and did not look too carefully.
I guess the OP should do it like this, to keep the same structure as the original code :

const char *msg2[] = "2";
. . .
. . .
. . .
{
   driver.send((uint8_t *)msg2, strlen( *msg2 ));
    . . .
    . . .
}

I wasn't able to get the last suggestion to work, but I simplified it into a matrix and was able to get it to work.

Here is 3 light version
Transmitter

if (c[0]== 1){
  digitalWrite(led1pin, LOW);
  d[0]=1;
}
else {
  digitalWrite(led1pin, LOW);
  d[0]=0;
}

Receiver

#include <RH_ASK.h>
#ifdef RH_HAVE_HARDWARE_SPI
#include <SPI.h> // Not actually used but needed to compile
#endif

RH_ASK driver (2000, 11, 12, 0);

int led1pin= 2;
int led2pin= 3;
int led3pin= 4;
int d[3]={0};//LED states
int b[3]={0};//Incoming Signal
int c[3]={0};//Combine state and signal
void setup() {

#ifdef RH_HAVE_SERIAL
    Serial.begin(9600);    // Debugging only
    
#endif
    if (!driver.init())
#ifdef RH_HAVE_SERIAL
         Serial.println("init failed");
#else
  ;
#endif

pinMode (led1pin, OUTPUT);
pinMode (led2pin, OUTPUT);
pinMode (led3pin, OUTPUT);
}

void loop() {
  
  for (int i = 0; i < 3; i++ ) {
    b[i] = 0;
}
    uint8_t buflen = sizeof(b);
    if (driver.recv((uint8_t*)b, &buflen)) {

    for (byte i = 0; i < 3; i++) {
      Serial.print(b[i]);
}
}
for (int i=0; i<3; i++ ) { c[i] = b[i] + d[i]; } //Combine state with signal

if (c[0]== 1){
  digitalWrite(led1pin, HIGH);
  d[0]=1;
}
if (c[0]!= 1) {
  digitalWrite(led1pin, LOW);
  d[0]=0;
}
if (c[1]== 1){
  digitalWrite(led2pin, HIGH);
  d[1]=1;
}
if (c[1]!= 1){
  digitalWrite(led2pin, LOW);
  d[1]=0;
}






for (int i = 0; i < 3; i++ ) {
    b[i] = 0;
}
}

Thanks for all the help!