0

I've got the following:

#include <SoftwareSerial.h>

const int rx = -1;
const int tx = 4;

SoftwareSerial mySerial(rx, tx);

void setup() 
{ 
  mySerial.begin(2400);
  pinMode(tx, OUTPUT);
} 

void loop() 
{ 
  if(mySerial.available())
  {
    String data = "Hello World";

    for(int k = 0; k < data.length(); k++ )
    {
      mySerial.write(0xAA);
      mySerial.write(data[k]);
    }

    mySerial.write(0xA9);
  }

  delay(1000);
}

Which I'm trying to send to to a RF transmitter module. It all compiles just fine, but am I forgetting something? And does pin 4 = physical pin 3?

  • You haven't told us what doesn't work! And how you are testing it? What is on the receiving end. PS arduin-pin-4 is indeed on attiny-pin-3, i.e. in most cores. – Gerben Jun 29 '14 at 16:14
1

In your loop function you have:

if(mySerial.available())
{
  String data = "Hello World";

  for(int k = 0; k < data.length(); k++ )
  {
    mySerial.write(0xAA);
    mySerial.write(data[k]);
  }

  mySerial.write(0xA9);
}

The available() function returns the number of bytes available in the receive buffer. You say your module is a transmitter, so there will never be any data to receive (I can see the module doesn't even have a tx pin). Hence you will never transmit any data.

That said it's not a good idea to send data plain over wireless. It might work to some extent, but you'll likely get much more lost data. Look at the virtual wire library or google "manchester coding" if you wan't to roll your own.

0

First off, are you trying to send to the 433MHz transmitter? This will not work. If you mean you are using the 433MHz transmitter to send data to a receiver, the VirtualWire.h library work.

If you are using another transmitter please add more info on the transmitter used in this project.

HumanHarddrive on youtube got a tutorial on the DX transmitter and receiver. Tutorial

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.