Question 433mhz transmitter and receiver.

Hello i was wondering if someone can help me out i have bough the rf 315mhz transmitter and receiver i know from looking the 315 and 433 are close to same will work the kind of the same i think but i was wondering if anyone know where i can find a sketch that can turn on 2 leds or more i found a place that haves something but when the button is pushed the led flashes not sure why that is. not good at rf stuff i need help i posted below the tx and rx sketches can someone help me out please?

RX

#include <VirtualWire.h>

void setup()
{
    Serial.begin(9600);    //Debugging
    Serial.println("setup");

    //Inisial IO dan ISR
    vw_set_ptt_inverted(true); // ibutuhkan untuk DR3100
    vw_setup(2000);     //Bits per sec
    vw_set_rx_pin(2);
    vw_rx_start();       //memulai receiver

pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
pinMode(11, OUTPUT);
}

void loop()
{
  digitalWrite(8, LOW);
  digitalWrite(9, LOW);
  digitalWrite(10, LOW);
  digitalWrite(11, LOW);
 
    uint8_t buf[VW_MAX_MESSAGE_LEN];
    uint8_t buflen = VW_MAX_MESSAGE_LEN;

    if (vw_get_message(buf, &buflen))
    {
    int i;

/*lampu menyala sebagai indikator pesan terkirim*/
        digitalWrite(13, true);
       // menerima pesan checksum
       Serial.print("Menerima: ");
   
    for (i = 0; i < buflen; i++)
    {
        Serial.print(buf[i]);
        if(buf[i] == '1'){digitalWrite(8, HIGH);}
        if(buf[i] == '2'){digitalWrite(9, HIGH);}
        if(buf[i] == '3'){digitalWrite(10, HIGH);}
        if(buf[i] == '4'){digitalWrite(11, HIGH);}
        Serial.print(" ");
    }
    Serial.println("");
        digitalWrite(13, false);

   }
}

Tx

#include <VirtualWire.h>

void setup()
{
    Serial.begin(9600);      // Debugging
    Serial.println("setup");

    // inisial IO dan ISR
    vw_set_ptt_inverted(true); // dibutuhkan untuk DR3100
    vw_setup(2000);     // Bits per sec
    vw_set_tx_pin(3);
       
        pinMode(8, INPUT);
        pinMode(9, INPUT);
        pinMode(10, INPUT);
        pinMode(11, INPUT);

digitalWrite(8, HIGH);
digitalWrite(9, HIGH);
digitalWrite(10, HIGH);
digitalWrite(11, HIGH);
}

void loop()
{
  char *msg;
 
  if(digitalRead(8) == LOW){
    char *msg = "1";

//lampu indikator untuk proses pengiriman
    digitalWrite(13, true);
    vw_send((uint8_t *)msg, strlen(msg));
    vw_wait_tx(); //menunggu hingga semua pesan hilang
    digitalWrite(13, false);}
  if(digitalRead(9) == LOW){
    char *msg = "2";
//lampu indikator untuk proses pengiriman
    digitalWrite(13, true); 
    vw_send((uint8_t *)msg, strlen(msg));
    vw_wait_tx(); //menungu hinga semua pesan hilang
    digitalWrite(13, false);}
  if(digitalRead(10) == LOW){
    char *msg = "3";
//lampu indikator untuk proses pengiriman 
    digitalWrite(13, true); 
    vw_send((uint8_t *)msg, strlen(msg));
    vw_wait_tx(); //menungu hinga semua pesan hilang
    digitalWrite(13, false);}
  if(digitalRead(11) == LOW){
    char *msg = "4";
//lampu indikator untuk proses pengiriman 
    digitalWrite(13, true); 
    vw_send((uint8_t *)msg, strlen(msg));
    vw_wait_tx(); //menungu hinga semua pesan hilang
    digitalWrite(13, false);}
  }

What i would like to do is when the button is pushed the led comes on and stays on and if pushed again led goes off on all 4 of them or at least two of them if can someone please help me?

hello i still can't figure this whole rf stuff out can someone please help me with this led push button idea thank you.

Your receiver code was turning the LEDs off because they were being told to turn off at the beginning of every loop. However, if you only turn off the LED when you don’t receive anything then they should not flicker.

RX

#include <VirtualWire.h>

void setup()
{
    Serial.begin(9600);    //Debugging
    Serial.println("setup");

    //Inisial IO dan ISR
    vw_set_ptt_inverted(true); // ibutuhkan untuk DR3100
    vw_setup(2000);     //Bits per sec
    vw_set_rx_pin(2);
    vw_rx_start();       //memulai receiver

pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
pinMode(11, OUTPUT);
}

void loop()
{ 
    uint8_t buf[VW_MAX_MESSAGE_LEN];
    uint8_t buflen = VW_MAX_MESSAGE_LEN;

    if (vw_get_message(buf, &buflen))
    {
    int i;

/*lampu menyala sebagai indikator pesan terkirim*/
        digitalWrite(13, true);
       // menerima pesan checksum
       Serial.print("Menerima: ");
   
    for (i = 0; i < buflen; i++)
    {
        Serial.print(buf[i]);
        if(buf[i] == '1'){digitalWrite(8, HIGH);}
        if(buf[i] == '2'){digitalWrite(9, HIGH);}
        if(buf[i] == '3'){digitalWrite(10, HIGH);}
        if(buf[i] == '4'){digitalWrite(11, HIGH);}
        Serial.print(" ");
    }
    Serial.println("");
        digitalWrite(13, false);

   }
   else // if you get nothing, then LED off.
   {
     digitalWrite(8, LOW);
     digitalWrite(9, LOW);
     digitalWrite(10, LOW);
     digitalWrite(11, LOW);
   }
}

hello not even sure how i can do that i tried to figure this out but i can’t seem to get it to stay on the led when pushed once and pushed second time to stay off just nothing but flashing when trying to click it.

So wait you want to toggle it? Press once = ON, press again = OFF?

right now what i uploaded the original sketch for tx and rx when pressed led just flashes but the rx did you change something because for some reason it does the same flashes but with the original code and the one you change no matter what led is dim comes on low flashing.

Did you remember the pulls own resistors for each of the buttons?

yes i have 10k ohm resistors. on the right side of the button jumper goes to pin 3 left side of the button and on the left side of the button goes to ground also left side resistor goes to 5v correct?

(5V)-------------{button}—x-------------(Gnd)
|
|
(Ard pin)

Did it that way yes that didn't work still the same flashing. I think also the transmitting might be off the guy on YouTube I talk to had this wasn't in english but I tried to sed him a message but no reply back.

What LED is flashing, the onboard LED next to pin 13?

i will take a short video from my cellphone to show and i will upload to my hosting and make a link to give to you.

here is a short video on it. www.codehunter.info/MOV_0281.mp4

Try this.

Tx:

#include <VirtualWire.h>

void setup()
{
  Serial.begin(9600);      // Debugging
  Serial.println("setup");

  // inisial IO dan ISR
  vw_set_ptt_inverted(true); // dibutuhkan untuk DR3100
  vw_setup(2000);     // Bits per sec
  vw_set_tx_pin(3);

  pinMode(8, INPUT);
  pinMode(9, INPUT);
  pinMode(10, INPUT);
  pinMode(11, INPUT);

  digitalWrite(8, HIGH);
  digitalWrite(9, HIGH);
  digitalWrite(10, HIGH);
  digitalWrite(11, HIGH);
}

void loop()
{
  char *msg;

  if(digitalRead(8) == LOW)
  {
    msg = "1";
    digitalWrite(13, true);
  }
  else if(digitalRead(9) == LOW){
    msg = "2";
    digitalWrite(13, true); 
  }
  else if(digitalRead(10) == LOW)
  {
    msg = "3";
    digitalWrite(13, true); 
  }
  else if(digitalRead(11) == LOW)
  {
    msg = "4";
    digitalWrite(13, true); 
  }
  else 
    msg = "0";
    
  vw_send((uint8_t *)msg, strlen(msg));
  vw_wait_tx();
  digitalWrite(13, false);

}

Rx:

#include <VirtualWire.h>
char lastchar = '0';

void setup()
{
  Serial.begin(9600);    //Debugging
  Serial.println("setup");

  //Inisial IO dan ISR
  vw_set_ptt_inverted(true); // ibutuhkan untuk DR3100
  vw_setup(2000);     //Bits per sec
  vw_set_rx_pin(2);
  vw_rx_start();       //memulai receiver

  pinMode(8, OUTPUT);
  pinMode(9, OUTPUT);
  pinMode(10, OUTPUT);
  pinMode(11, OUTPUT);
}

void loop()
{ 
  uint8_t buf[VW_MAX_MESSAGE_LEN];
  uint8_t buflen = VW_MAX_MESSAGE_LEN;

  if (vw_get_message(buf, &buflen))
  {
    // menerima pesan checksum
    Serial.print("Menerima: ");
    Serial.print(buf[0]);
    Serial.print(" ");

    if(buf[0] == '1' && buf[0] != lastchar )
    {
      digitalWrite(8, !digitalRead(8));
    }
    else if(buf[0] == '2' && buf[0] != lastchar )
    {
      digitalWrite(9, !digitalRead(9));
    }
    else if(buf[0] == '3' && buf[0] != lastchar )
    {
      digitalWrite(10, !digitalRead(10));
    }
    else if(buf[0] == '4' && buf[0] != lastchar )
    {
      digitalWrite(11, !digitalRead(11));
    }
    lastchar = buf[0];
  }
}

for some reason i can't get nothing to come up now on the transmit thebutton left side is to 5v right side is resistor to gnd and jumper from button right side to D8 it flashed before but now nothing happening.

wait a minute doesn't the tx haves the led low and high set but you have it on Tx transmit side now?

If you press the button, does it go HIGH or LOW?

This here in the transmitter code is setting the buttons HIGH and wanting them to go low to send out a message. You might need to comment this part out, but first what do you have?

digitalWrite(8, HIGH); digitalWrite(9, HIGH); digitalWrite(10, HIGH); digitalWrite(11, HIGH);

when i hit the button nothing happens at all no flashing no nothing. but if i put led in put d10 it lights up so i put button in 10 to match it and try to hit it and nothing happens stays on.

Try this, it should work now. You should see on onboard led next to pin 13 come on when you press a button.

#include <VirtualWire.h>

void setup()
{
  Serial.begin(9600);      // Debugging
  Serial.println("setup");

  // inisial IO dan ISR
  vw_set_ptt_inverted(true); // dibutuhkan untuk DR3100
  vw_setup(2000);     // Bits per sec
  vw_set_tx_pin(3);

  pinMode(8, INPUT);
  pinMode(9, INPUT);
  pinMode(10, INPUT);
  pinMode(11, INPUT);
}

void loop()
{
  char *msg;

  if(digitalRead(8) == HIGH)
  {
    msg = "1";
    digitalWrite(13, true);
  }
  else if(digitalRead(9) == HIGH){
    msg = "2";
    digitalWrite(13, true); 
  }
  else if(digitalRead(10) == HIGH)
  {
    msg = "3";
    digitalWrite(13, true); 
  }
  else if(digitalRead(11) == HIGH)
  {
    msg = "4";
    digitalWrite(13, true); 
  }
  else 
    msg = "0";
    
  vw_send((uint8_t *)msg, strlen(msg));
  vw_wait_tx();
  digitalWrite(13, false);

}

Post a picture of how your button is wired.