Help with RC 433 Mhz Programming

Hi all,
I am new here, I my arduino uno almost 1 year and I have not so much experience, I learn Programming in school (processing) but it doesen t help much.
Also I buyed an RC kit 433 Mhz ( http://i00.i.aliimg.com/wsphoto/v0/1308017760/1pcs-433Mhz-font-b-RF-b-font-font-b-transmitter-b-font-and-font-b-receiver.jpg) and I learned how it works and it works but I have a question this program line that I found it works but I don t know if i can turn on led`s separatly. Here is the code for the transmitter:

#include <VirtualWire.h>
char *controller;
void setup()
 { 
vw_set_ptt_inverted(false); //
vw_set_tx_pin(12);
vw_setup(4000);// speed of data transfer Kbps
}
void loop()
{
controller="0"  ;
vw_send((uint8_t *)controller, strlen(controller));
delay (500);
controller="1"  ;
vw_send((uint8_t *)controller, strlen(controller));
 delay(200);
}

here is the code for the receiver:

#include <VirtualWire.h>
void setup()
{
    vw_set_ptt_inverted(true); // Required for DR3100
    vw_set_rx_pin(12);
    vw_setup(9000);  // Bits per sec
    pinMode(13, OUTPUT);
    pinMode(11, OUTPUT);
    vw_rx_start();       // Start the receiver PLL running
}
    void loop()
{
    uint8_t buf[VW_MAX_MESSAGE_LEN];
    uint8_t buflen = VW_MAX_MESSAGE_LEN;
    if (vw_get_message(buf, &buflen)) // Non-blocking
    {
      if(buf[0]=='1')
{
   digitalWrite(13,1);
         }  
   if(buf[0]=='0')
{
  digitalWrite(13,0);
    }
        uint_t buf[VW_MAX_MESSAGE_LEN];
    uint_t buflen = VW_MAX_MESSAGE_LEN;
    if (vw_get_message(buf, &buflen)) // Non-blocking
    {
      if(buf[0]=='1')
{
   digitalWrite(11,1);
      }  
   if(buf[0]=='0'){
  digitalWrite(11,0);
    }
}
}

As I am new here could someone help me or at least give me a hint how to make that the transmieter turns the lets on separatly, then I would do it with the serial monitor.
I tried to search the internet but there are just the basics , no this types of questions.
I hope you can help me :slight_smile:
Regards,
Von

The code you posted does something. You didn't say what.
You want it to do something. What that is is not at all clear.

It's hard to help without knowing what the code actually does, and how that differs from what you want.

And, please, no more marque shit. That feature is the most annoying thing you can put in a post.

I won t , sorry i didn t know.

So the cose does this: The transmitor sends a signal to the reciver which makes led turn on and of ( I put the delay to 200 , but defaults was 2000) , it is the basic that i found on a page(http://www.instructables.com/id/RF-315433-MHz-Transmitter-receiver-Module-and-Ardu/all/?lang=de) It is just a test code to see how it works, and i would like to know how to turn 2 leds on and of ( or blinking) separatly. I wouldn t put leds i will put relais when i push button 1 relais 1 goes on, when i push button 2 relais 2 goes on etc..

As i see here ( trasmiter code) this regulates the sending but it sends a signal to all just to turn on , so if i have 20 leds it would turn on all.

void loop()
{
controller="0"  ;
vw_send((uint8_t *)controller, strlen(controller));

controller="1"  ;
vw_send((uint8_t *)controller, strlen(controller));

}

and i would like to know how to turn 2 leds on and of ( or blinking) separatly

So, "0" and "1" turn one LED on and off. Pick two other characters for the other LED.

I wouldn t put leds i will put relais when i push button 1 relais 1 goes on, when i push button 2 relais 2 goes on etc..

Connecting a relay to the pin instead of an LED makes no difference to the code.

Connecting a relay to the pin instead of an LED makes no difference to the code.

I know i just wanted to say for what i need.

i tried this with 1 and 0 but it doesent work with other numbers
recever

    void loop()
{
    uint8_t buf[VW_MAX_MESSAGE_LEN];
    uint8_t buflen = VW_MAX_MESSAGE_LEN;
    if (vw_get_message(buf, &buflen)) // Non-blocking
    {
      if(buf[0]=='1');  
   digitalWrite(13,1);
      }  
   if(buf[0]=='0')
   {
  digitalWrite(13,0);
    }    
  if(buf[0]=='2'){ 
      digitalWrite(11,1);
      }  
   if(buf[0]=='3'){
   digitalWrite(11,0);
     }
    }
    }

transmiter

#include <VirtualWire.h>
char *controller;
void setup() {
vw_set_ptt_inverted(false); //
vw_set_tx_pin(12);
vw_setup(9000);// speed of data transfer Kbps
}
void loop(){
controller="0"  ;
vw_send((uint8_t *)controller, strlen(controller));
delay (500);
controller="1"  ;
vw_send((uint8_t *)controller, strlen(controller));
delay(200);
controller="2"  ;
vw_send((uint8_t *)controller, strlen(controller));
delay (5005);
controller="3"  ;
vw_send((uint8_t *)controller, strlen(controller));
 }

You REALLY need to learn to use Tools + Auto Format.

      if(buf[0]=='1');

If you got a '1', do nothing ( ; ). Otherwise, do nothing. What was the point in testing?

Then, regardless of whether you receive anything, or not, check what you received, and take some action.

   if(buf[0]=='0')
   {
  digitalWrite(13,0);
    }    
  if(buf[0]=='2'){ 
      digitalWrite(11,1);
      }  
   if(buf[0]=='3'){
   digitalWrite(11,0);
     }

No!

Resolved , it works, i made it with serial monitor:

transmiter:

void loop(){
  input = Serial.read();      // read the serial port
 if (input == '1' )
 {
controller="1"  ;
vw_send((uint8_t *)controller, strlen(controller));
   Serial.println("LED1 is ON");
 }
  if (input == '3' )
  {

controller="0"  ;
vw_send((uint8_t *)controller, strlen(controller));
 Serial.println("LED1 is OFF");
  }

 if (input == '2' ) {

controller="2"  ;
vw_send((uint8_t *)controller, strlen(controller));
 Serial.println("LED2 is ON");
 }
  if (input == '4' ) {
controller="3"  ;
vw_send((uint8_t *)controller, strlen(controller));
 Serial.println("LED2 is OFF");
  }

receiver

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

    if (vw_get_message(buf, &buflen)) // Non-blocking
    {
      if(buf[0]=='1'){

  
   digitalWrite(13,1);
   
      }  
   if(buf[0]=='0')
   {
  digitalWrite(13,0);

    }
    


    
  if(buf[0]=='2'){ 
   
   digitalWrite(11,1);
      }  
   if(buf[0]=='3'){
 
  digitalWrite(11,0);
  
   }
    }
    }

thx all for helping :slight_smile: