Hi, i recently ordered a 434MHz RF link transmitter (RF Link Transmitter - 434MHz - WRL-10534 - SparkFun Electronics) and a 434MHz RF link receiver (RF Link Receiver - 4800bps (434MHz) - WRL-10532 - SparkFun Electronics). I have been trying to test them to make sure they work and learn how to use them together but i can not seem to have any success with establishing a link. I am using an Arduino Uno for the receiver and an Arduino Micro for the Transmitter. In my code i use the Virtual Wire library (VirtualWire: VirtualWire library for Arduino and other boards).
Below is my code for the transmitter(Arduino Micro):
// Transmitter (micro)
#include <VirtualWire.h>
#include <VirtualWire_Config.h>
void setup(){
Serial.begin(9600);
vw_setup(4800); //Sparkfuns recommended bps rate
vw_set_tx_pin(10); //im using pin 10 as the TX
}
void loop(){
if(Serial.available()){
char c = Serial.read();
if(c == '1'){
vw_send((uint8_t *)c, 1); //type '1' = send '1'
}
else if(c == '0'){
vw_send((uint8_t *)c, 1); //type '0' = send '0'
}
}
}
And my code for the receiver (Arduino Uno):
// Reciever (uno)
#include <VirtualWire.h>
#include <VirtualWire_Config.h>
void setup(){
pinMode(13,OUTPUT);
digitalWrite(13,LOW);
vw_set_ptt_inverted(true);
vw_setup(4800); //Sparkfuns recommended bps rate
vw_set_rx_pin(10); //im using pin 10 as the RX
vw_rx_start();
}
void loop(){
uint8_t buflen = VW_MAX_MESSAGE_LEN;
uint8_t buf[buflen];
if(vw_get_message(buf, &buflen)){
for(int i = 0;i < buflen; i++){
if(buf[i] == '1'){
digitalWrite(13,HIGH); //if the Uno receives a '1' turn the built in led on pin 13 HIGH
}
else if(buf[i] == '0'){
digitalWrite(13,LOW); ////if the Uno receives a '0' turn the built in led on pin 13 LOW
}
}
}
}
If anyone could help me it would be very appreciated, i have been trying to figure this out for quite some time. The problem may not be in my code but i looked up my wiring and i am pretty positive that it is fine. It might be helpful to mention i have my receiver(Uno) on a 9 volt battery supply about 5 feet away from my computer and transmitter(Micro).
Again thank you for your help.