Go Down

Topic: RF Transmitter and Receiver (Read 2832 times) previous topic - next topic

rascarnascar

Hi all. I'm having trouble programming this RF transmitter and Receiver pair from parallax. The following program is one a took from several other locations online. I think the problem is "syncing" the receiver with the transmitter. Here is my code and links to the parallax information.

This is the receiver code:
Code: [Select]
[#include <SoftwareSerial.h>
#define rxRF 4


int incomingByte = 0;

SoftwareSerial rfSerial = SoftwareSerial(rxRF, 8);

void setup() {
   
pinMode(rxRF, INPUT);
rfSerial.begin(2400);
Serial.begin(9600);
}

void loop() {

incomingByte = rfSerial.read();
Serial.println(incomingByte);
delay(1000);

}


]



This is the transmitter code:

[code]#include <SoftwareSerial.h>

#define txRF 3

SoftwareSerial rfSerial = SoftwareSerial(13,txRF);
int outgoingByte= 1;

void setup() {
  pinMode(txRF,OUTPUT);
  rfSerial.begin(2400);
  Serial.begin(9600);
 
}

void loop() {
 
  rfSerial.print(outgoingByte);
  Serial.println(outgoingByte);
  delay(1000);
 
}[]

The links to the transmitter/receiver info is :

http://www.parallax.com/Portals/0/Downloads/docs/prod/rf/27980-ParallaxRFTransmit-v1.1.pdf
[/code]

johnwasser

With SoftwareSerial you have to be sitting in the .read() function when the character arrives or it will be missed.  Delaying a second between reads would miss a lot of data.  Are you receiving ANY data?

Try these changes:

This is the receiver code:
Code: [Select]

#include <SoftwareSerial.h>
#define rxRF 4
#define txRF 8

SoftwareSerial rfSerial = SoftwareSerial(rxRF,txRF);

void setup()
  {
  pinMode(rxRF, INPUT);
  pinMode(txRF, OUTPUT);
  rfSerial.begin(2400);
  Serial.begin(9600);
  }



void loop()
  {
  byte incomingByte = rfSerial.read();
  Serial.println(incomingByte);
  }



This is the transmitter code:

Code: [Select]

#include <SoftwareSerial.h>
#define rxRF 13
#define txRF 3

SoftwareSerial rfSerial = SoftwareSerial(rxRF,txRF);

void setup()
  {
  pinMode(rxRF, INPUT);
  pinMode(txRF, OUTPUT);
  rfSerial.begin(2400);
  }

void loop()
  {
  rfSerial.print('$');
  delay(1000);
  }
Send Bitcoin tips to: 1G2qoGwMRXx8az71DVP1E81jShxtbSh5Hp

rascarnascar

Thank you very much! It is printing now.

Go Up