RF TRANSMITTER AND RECEIVER

Discussion in 'Programmer's Corner' started by AJIN NADH, Feb 18, 2015.

  1. AJIN NADH

    Thread Starter Member

    Dec 18, 2014
    79
    4
    Hi,
    I used rf 433 mhz transmitter and receiver to transmitt bit 1 and 0, But its not working properly , is it need DECODER Ic...?
    am attaching the arduino program and photo of the transreceiver

    Code (Text):
    1.  
    2. //simple Tx on pin D12
    3. //Written By : Mohannad Rawashdeh
    4. // 3:00pm , 13/6/2013
    5. //[URL]http://www.genotronex.com/[/URL]
    6. //..................................
    7. #include <VirtualWire.h>
    8. char *controller;
    9. void setup() {
    10.   pinMode(13,OUTPUT);
    11. vw_set_ptt_inverted(true); //
    12. vw_set_tx_pin(12);
    13. vw_setup(4000);// speed of data transfer Kbps
    14. }
    15.  
    16. void loop(){
    17. controller="1"  ;
    18. vw_send((uint8_t *)controller, strlen(controller));
    19. vw_wait_tx(); // Wait until the whole message is gone
    20. digitalWrite(13,1);
    21. delay(2000);
    22. controller="0"  ;
    23. vw_send((uint8_t *)controller, strlen(controller));
    24. vw_wait_tx(); // Wait until the whole message is gone
    25. digitalWrite(13,0);
    26. delay(2000);
    27.  
    28. }
    29.  
    and this is code for receiver :

    The D13 LED On the arduino board must be turned ON when received character '1' and Turned Off when received character '0'

    Code (Text):
    1.  
    2. //simple Tx on pin D12
    3. //Written By : Mohannad Rawashdeh
    4. // 3:00pm , 13/6/2013
    5. //[URL]http://www.genotronex.com/[/URL]
    6. //..................................
    7. #include <VirtualWire.h>
    8. void setup()
    9. {
    10.   vw_set_ptt_inverted(true); // Required for DR3100
    11.   vw_set_rx_pin(12);
    12.   vw_setup(4000);  // Bits per sec
    13.   pinMode(13, OUTPUT);
    14.  
    15.   vw_rx_start();  // Start the receiver PLL running
    16. }
    17.   void loop()
    18. {
    19.   uint8_t buf[VW_MAX_MESSAGE_LEN];
    20.   uint8_t buflen = VW_MAX_MESSAGE_LEN;
    21.  
    22.   if (vw_get_message(buf, &buflen)) // Non-blocking
    23.   {
    24.   if(buf[0]=='1'){
    25.  
    26.  
    27.   digitalWrite(13,1);
    28.   }
    29.   if(buf[0]=='0'){
    30.   digitalWrite(13,0);
    31.   }
    32.  
    33. }
    34. }
    35.  

    Regards,
    Ajin Nadh

    Moderators note: Please use code tags for pieces of code
     
    Last edited by a moderator: Feb 20, 2015
  2. Brevor

    Active Member

    Apr 9, 2011
    279
    54
    What do you mean by "not working properly"?
     
  3. MikeML

    AAC Fanatic!

    Oct 2, 2009
    5,450
    1,066
  4. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,386
    1,605
  5. AJIN NADH

    Thread Starter Member

    Dec 18, 2014
    79
    4
    WHEN I SEND THE EVENTS THE RECEIVER LED NOT BLINKING
     
  6. AJIN NADH

    Thread Starter Member

    Dec 18, 2014
    79
    4
    does the antenna length affect this...?
     
  7. MikeML

    AAC Fanatic!

    Oct 2, 2009
    5,450
    1,066
    How far are you trying to send? You need an antenna on both Tx and Rx. If either is missing, you will be lucky to get across the room.
     
  8. AJIN NADH

    Thread Starter Member

    Dec 18, 2014
    79
    4
    Ya I used antenna, and trying to send from very close
     
  9. MikeML

    AAC Fanatic!

    Oct 2, 2009
    5,450
    1,066
    Did you read and follow Roman's excellent article?
     
  10. AJIN NADH

    Thread Starter Member

    Dec 18, 2014
    79
    4
    NO
     
  11. RRITESH KAKKAR

    Senior Member

    Jun 29, 2010
    2,831
    89
    Holtek 12e/d Best way to go with module.
     
Loading...