# Looking for code

**URL:** <https://forum.arduino.cc/t/looking-for-code/1105370>\
**Category:** Programming\
**Created:** [March 22, 2023, 8:13pm UTC](https://forum.arduino.cc/t/looking-for-code/1105370 "2023-03-22T20:13:05Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![noomgod79](https://avatars.discourse-cdn.com/v4/letter/n/a8b319/32.png) [@noomgod79](https://forum.arduino.cc/u/noomgod79)\
**Post date:** [March 22, 2023, 8:13pm UTC](https://forum.arduino.cc/t/looking-for-code/1105370/1 "2023-03-22T20:13:05Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![apf1979](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/apf1979/32/966781_2.png) [@apf1979](https://forum.arduino.cc/u/apf1979)\
**Post date:** [March 22, 2023, 8:19pm UTC](https://forum.arduino.cc/t/looking-for-code/1105370/2 "2023-03-22T20:19:50Z")

</div>

> [@How to get the best out of this forum](https://forum.arduino.cc/t/how-to-get-the-best-out-of-this-forum/679966):
>
> See also [FAQ - Arduino Forum](https://forum.arduino.cc/faq) for general rules on forum behaviour and etiquette. Hello, Welcome to the Arduino Forum. This guide explains how to get the best out of this forum. Please read and follow the instructions below. Being new here you might think this is having rules for the sake of rules, but that is not the case. If you don’t follow the guidelines all that happens is there is a long exchange of posts while we try to get you to tell us what we need in order to help you, which is fru…

Post all schematics, pictures, and part models.

---

<div class="post-metadata">

**Author:** ![groundFungus](https://avatars.discourse-cdn.com/v4/letter/g/73ab20/32.png) [@groundFungus](https://forum.arduino.cc/u/groundFungus)\
**Post date:** [March 22, 2023, 8:22pm UTC](https://forum.arduino.cc/t/looking-for-code/1105370/3 "2023-03-22T20:22:49Z")

</div>

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

First [please read the forum guidelines](https://forum.arduino.cc/t/how-to-get-the-best-out-of-this-forum/679966) 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)](https://www.tutorialspoint.com/auto-format-code-in-arduino-ide) 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](https://europe1.discourse-cdn.com/arduino/original/4X/6/d/6/6d66e052e6d1ec9113aa9b604b81002f273fd482.jpeg)  
Make sure to make and attach antennas to the modules. Mine would not work without antennas.

---

<div class="post-metadata">

**Author:** ![noomgod79](https://avatars.discourse-cdn.com/v4/letter/n/a8b319/32.png) [@noomgod79](https://forum.arduino.cc/u/noomgod79)\
**Post date:** [March 22, 2023, 8:36pm UTC](https://forum.arduino.cc/t/looking-for-code/1105370/4 "2023-03-22T20:36:49Z")

</div>

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

```cpp
#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);
}

```

---

<div class="post-metadata">

**Author:** ![anon57585045](https://avatars.discourse-cdn.com/v4/letter/a/ed8c4c/32.png) [@anon57585045](https://forum.arduino.cc/u/anon57585045)\
**Post date:** [March 22, 2023, 8:41pm UTC](https://forum.arduino.cc/t/looking-for-code/1105370/5 "2023-03-22T20:41:45Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![DaveX](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/davex/32/751443_2.png) [@DaveX](https://forum.arduino.cc/u/DaveX)\
**Post date:** [March 22, 2023, 8:54pm UTC](https://forum.arduino.cc/t/looking-for-code/1105370/6 "2023-03-22T20:54:30Z")

</div>

Does this work?

> **[How To Use Lora With Arduino](https://projecthub.arduino.cc/noneedforit/dcf3c8bd-9243-4098-9ced-1186208350f1)**
>
> Basic Interface Of Lora With Arduino

---

<div class="post-metadata">

**Author:** ![groundFungus](https://avatars.discourse-cdn.com/v4/letter/g/73ab20/32.png) [@groundFungus](https://forum.arduino.cc/u/groundFungus)\
**Post date:** [March 22, 2023, 8:59pm UTC](https://forum.arduino.cc/t/looking-for-code/1105370/7 "2023-03-22T20:59:49Z")

</div>

Can you answer the other requests?

> [@groundFungus](#):
>
> For a start, which Arduino board and please provide technical data for your exact radio modules.

> [@groundFungus](#):
>
> If you have built a circuit, please include a schematic.

---

<div class="post-metadata">

**Author:** ![paulpaulson](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/paulpaulson/32/363643_2.png) [@paulpaulson](https://forum.arduino.cc/u/paulpaulson)\
**Post date:** [March 23, 2023, 4:04am UTC](https://forum.arduino.cc/t/looking-for-code/1105370/8 "2023-03-23T04:04:28Z")

</div>

> [@noomgod79](#):
>
> 433mhz transmitter & receiver

Which type of RXTX module is used?

---

<div class="post-metadata">

**Author:** ![StefanL38](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/stefanl38/32/713548_2.png) [@StefanL38](https://forum.arduino.cc/u/StefanL38)\
**Post date:** [March 23, 2023, 6:54am UTC](https://forum.arduino.cc/t/looking-for-code/1105370/9 "2023-03-23T06:54:00Z")

</div>

> [@noomgod79](#):
>
> 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 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

> **[3Pcs Geekcreit® DC 12V 10A Relay 1CH Channel Wireless RF Remote Control...](https://uk.banggood.com/3Pcs-Geekcreit-DC-12V-10A-Relay-1CH-Channel-Wireless-RF-Remote-Control-Switch-p-1188168.html?imageAb=1&rmmds=detail-left-hotproducts&cur_warehouse=HK&a=1679554403.369&DCC=GB&currency=EUR&akmClientCountry=DE)**
>
> Only US$17.16, buy best 3Pcs Geekcreit® DC 12V 10A Relay 1CH Channel Wireless RF Remote Control Switch Transmitter With Receiver sale online store at wholesale price.

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

 ![image](https://europe1.discourse-cdn.com/arduino/original/4X/7/a/0/7a0fb3f8e4fa8ddfe5595d1b877f9a8abf6eb9eb.png)

---

<div class="post-metadata">

**Author:** ![anon57585045](https://avatars.discourse-cdn.com/v4/letter/a/ed8c4c/32.png) [@anon57585045](https://forum.arduino.cc/u/anon57585045)\
**Post date:** [March 24, 2023, 3:52pm UTC](https://forum.arduino.cc/t/looking-for-code/1105370/10 "2023-03-24T15:52:01Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [September 20, 2023, 3:52pm UTC](https://forum.arduino.cc/t/looking-for-code/1105370/11 "2023-09-20T15:52:09Z")

</div>

Closed on September 20, 2023, 3:52pm UTC

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