Looking for code

I have two Arduino boards with a 433mhz transmitter & receiver with the one Arduino wired up with the transmitter with an on/off switch that I'm trying to transmit to the receiver to deliver the on/off signal to a machine. Does anyone have code for this? I feel like I been running around in circles.

Post all schematics, pictures, and part models.

1 Like

Not a free code place. We are glad to help you learn, though.

First please read the forum guidelines to get to know what we need from you so that we can provide efficient help.

For a start, which Arduino board and please provide technical data for your exact radio modules.

Post the test code that you tried. Post the code in a code block as described in the how-to-get-the-best-out-of-this-forum linked above.

Use the IDE autoformat tool (ctrl-t or Tools, Auto format) before posting code in code tags.

If you are getting compile errors, please post the entire content of the error message.

If you have built a circuit, please include a schematic.

I used information from this page to get a cheap 433MHz transmitter and receiver to talk.

image
Make sure to make and attach antennas to the modules. Mine would not work without antennas.

2 Likes

This is what I have for the transmitter. I haven't done this for at least 15 years. Scratching my head.

#include <VirtualWire.h>
const int buttonPin = 2;  
const int ledPin = 13;    
const int dataout = 12;

int buttonState = 0;  

void setup() {
  pinMode(ledPin, OUTPUT);
  pinMode(buttonPin, INPUT);
  pinMode(dataout, OUTPUT);
}


void loop() {
  buttonState = digitalRead(buttonPin);
  if (buttonState == HIGH) {
       digitalWrite(ledPin, LOW);
    digitalWrite(dataout, 0);
  } else {
     digitalWrite(ledPin, HIGH);
    digitalWrite(dataout, 1);
}

If you intend to completely avoid any use of the VirtualWire library, there is no point in including the header file.

Also if you want to write your own TX/RX drivers for the devices, you have skipped over reams of information that you would need to do that.

You are setting sail without a map or compass... it's almost impossible that any working code could come from that.

Since you are "looking for code", have you looked at any of the VirtualWire example sketches that ship with it?

1 Like

Does this work?

Can you answer the other requests?

1 Like

Which type of RXTX module is used?

Does the received signal have to be on, on, on, on all the time until you switch the transmitter-switch off or is a pulse of what length enough?
Maybe a pulse of 0,1 seconds, 2 seconds?

Of course it can be done using two arduinos and RF-modules
For the described functionality a simple RF-remote-control seems to be sufficient

Edit: while searching for such a remote control I got this funny message I have never seen before

Actually, it is illegal to transmit continuously on 433MHz. The posted code does that. Also the receiver circuit will not decode a continuous signal properly.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.