0

This is a really basic problem, but I haven't been able to resolve it myself and would really appreciate the help. So I've been struggling for a few weeks now to set up RF communication between two arduino uno chips. I have the transmitter and receiver hooked up to 5V supply, with the data pins connected to digital pin 4. My code looks like this:

Transmitter code:

#define rfTransmitPin 4 //RF Transmitter pin = digital pin 4
#define ledPin 13 //Onboard LED = digital pin 13
unsigned int data = 0; // variable used to store transmission data
void setup(){
 pinMode(rfTransmitPin, OUTPUT); 
 pinMode(ledPin, OUTPUT); 
 Serial.begin(9600); 
}
void loop(){
 digitalWrite (rfTransmitPin, HIGH);
 data = digitalRead (rfTransmitPin); // Read the digital transmitter pin
 Serial.println(data);
 digitalWrite (ledPin, HIGH);
 delay(2000);
 digitalWrite (rfTransmitPin, LOW);
 data = digitalRead (rfTransmitPin); // Read the digital transmitter pin
 Serial.println(data);
 digitalWrite (ledPin, LOW);
 delay(2000);
 }

Receiver code:

#define rfReceivePin 4 //RF Receiver pin = digital pin 4
#define ledPin 13 //Onboard LED = digital pin 13
unsigned int data = 0; // variable used to store received data
void setup(){
 pinMode(ledPin, OUTPUT);
 pinMode(rfReceivePin, INPUT);
 Serial.begin(9600);
}
void loop(){
 data=digitalRead(rfReceivePin); //listen for data on Digital Pin 4
 if(data = HIGH){
 digitalWrite(ledPin, HIGH); //If a HIGH signal is received, turn LED ON
 Serial.println(data);
 }
 if(data = LOW){
 digitalWrite(ledPin, LOW); //If a LOW signal is received, turn LED OFF
 Serial.println(data);
 }
}

This should be really simple, but for some reason I'm reading a continual HIGH signal from the receiver module. I'm trying to sort out the basic functionality of the RF tx-rx pair before developing code to send a char using the Virtual Wire library, but I can't even get it to function at this level. Since my code is so basic I'm convinced it must be a hardware issue and I'm not sure what I'm doing wrong. Any suggestions?

asked Mar 11, 2017 at 3:11

1 Answer 1

1

VIf you using Virutalwire try exemple in the library. You can't send simple digitata data with Rf. Best Regards Mikael

link Virutalwire

answered Mar 11, 2017 at 7:05
5
  • Hi Mikael, thanks for the reply. I've tried running the example transmitter/receiver code, and all I get is the setup printout on the serial monitor, the message doesn't come through. Commented Mar 11, 2017 at 8:41
  • hackshed.co.uk/rf-communication-between-2-arduinos Commented Mar 12, 2017 at 3:08
  • This will you show you how you use VirutalWire Commented Mar 12, 2017 at 3:11
  • Turned out to be a faulty receiver, it's all working as it should be now :-) Commented Mar 12, 2017 at 4:12
  • 1
    Glad you got it working Commented Mar 12, 2017 at 5:43

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.