Need Help getting started

I'm am building an RC Tank. I'm using two MKR 1000 boards. I've got a 433 MHz Transmitter and Receiver modules. I found some code that is incomplete can anybody help me get it to work so that I can transmit data?

Transmitter Code

// oddWires: this is a simple exmaple that shows the 433Mhz module working. It sends a simple message to the receiver

#include

void setup()
{
// Initialise the IO and ISR
vw_set_ptt_inverted(true); // Required for RF Link module
vw_set_tx_pin(10); // pin 10 is used as the transmit data out to the TX Link module,

// change this to suit your needs.
}

void loop()
{
rfSend("this is a test");
delay(5000);
}

void rfSend(String message)
{
char output[100];

message.toCharArray(output, 99);

vw_setup(2000);
vw_send((uint8_t *)output, strlen(output));
vw_wait_tx(); // Wait for message to finish
vw_setup(40);
}

Receiver Code

// oddWires: this is a simple example that shows the 433Mhz module working. It receives simple message from the transmitter

#include

#define rxPin 2

const int ledPin = 13; // the number of the LED pin
int ledState = LOW; // ledState used to set the LED
long onMillis = 0; // will store last time LED was updated

void setup()
{
Serial.begin(9600);
pinMode(ledPin, OUTPUT);

// Initialise the IO and ISR
vw_set_ptt_inverted(true); // Required for RX Link Module
vw_setup(2000); // Bits per sec
vw_set_rx_pin(rxPin); // We will be receiving on pin 2 ie the RX pin from the module connects to this pin.
vw_rx_start(); // Start the receiver
}

void loop()
{
uint8_t buf[VW_MAX_MESSAGE_LEN];
uint8_t buflen = VW_MAX_MESSAGE_LEN;

if (vw_get_message(buf, &buflen)) // check to see if anything has been received
{
int i;
// Message with a good checksum received.

for (i = 0; i < buflen; i++)
{
Serial.print((char)buf*); // print the received data stored in buffer to the serial monitor*

  • }*
  • Serial.println(" ");*
  • digitalWrite(ledPin, HIGH);*
  • onMillis = millis();*
  • }*
  • if (millis() - onMillis > 100 && onMillis > 0)*
  • {*
  • onMillis = 0;*
  • digitalWrite(ledPin, LOW);*
  • }*
    }

Please remember to use code tags when posting code

Why do you think it is incomplete?

What do you expect it to do?
What does it actually do?
How do those 2 differ?

If you plan to use VirtualWire, start with the examples that you download with the library.

The examples you improperly posted use Strings, which is a bad idea and should be avoided.

vinceherman:
Why do you think it is incomplete?

#include

OP probably should have found that the sketches don't compile, due to (at least) the incomplete #include's.

jremington:
start with the examples

(So not the "exmaples"? :wink: )

// oddWires: this is a simple exmaple

I don't know if the MKR 1000 has existing code that would be used with the #include or if that's something that the person made and didn't make available.

Where I got the code:
https://www.oddwires.com/433-mhz-communication-between-arduinos/

Download VirtualWire and working examples here.

I'm not using Virtual Wire. I'm using Radio Frequency

I just found a Library for MHz RF in the Library Manager, ESPiLight by Puuu, would it work as complete base for the transmitter and receiver that I am using?

The Transmitter and receiver:
https://www.oddwires.com/433-mhz-transmitter-and-receiver-modules-great-for-arduino/

I'm not using Virtual Wire. I'm using Radio Frequency

You certainly are confused. These function calls:

vw_set_ptt_inverted(true);          // Required for RX Link Module
  vw_setup(2000);                     // Bits per sec
  vw_set_rx_pin(rxPin);               // We will be receiving on pin 2 ie the RX pin from the module connects to this pin.
  vw_rx_start();                      // Start the receiver
}

are very obviously to functions in the VirtualWire library.

It could be that someone has taken that library and renamed it, as a result of some peculiar mental problem, but that would be yet another reason to stay far away from wherever you got that code.

I tried the Virtual Wire link and tried to upload it, but it says that it is not compatible with the MKR 1000

Please read and follow the directions in the "How to use this forum" post.

Would PWM work for sending a signal to the transmitter? If so, how would I program it for the 27 different signals I would need to send?

Julius217:
Would PWM work for sending a signal to the transmitter? If so, how would I program it for the 27 different signals I would need to send?

That's how "digi-prop" RC systems have worked since the 1970s, albeit with far fewer channels, by combining PWM pulses into a PPM stream.

The reason there are so many "channels" is because I'm going to be using 3 switches on the controller and 3 motors on the tank.
I've never messed with PWM before, so how do I program it to do PWM?