rc switch

I have copied a sketch exactly as given from someone in arduino. It decodes radio frequency transmissions. I am getting the message “output not declared”. Can anybody tell me how I should declare it? Here is the sketch;

#include <RCSwitch.h>

RCSwitch mySwitch = RCSwitch();

void setup() {
mySwitch.enableReceive(0); // Receiver on interrupt 0 => that is pin #2

void loop() {
if (mySwitch.available()) {
output(mySwitch.getReceivedValue(), mySwitch.getReceivedBitlength(), mySwitch.getReceivedDelay(), mySwitch.getReceivedRawdata(),mySwitch.getReceivedProtocol());

output(mySwitch.getReceivedValue(), mySwitch.getReceivedBitlength(), mySwitch.getReceivedDelay(), mySwitch.getReceivedRawdata(),mySwitch.getReceivedProtocol()); The function “output” does not appear in the code you posted.

Please remember to use code tags when posting code

I have copied a sketch exactly as given from someone in arduino

Where exactly did you copy it from ?

That looks like ReceiveDemo_Advanced from codebender (https://codebender.cc/example/RCSwitch/ReceiveDemo_Advanced:output#ReceiveDemo_Advanced.ino).

I guess you didn't notice that the program is in 3 separate parts that all need including. Output is one of them.


That looks like ReceiveDemo_Advanced from codebender (https://codebender.cc/example/RCSwitch/ReceiveDemo_Advanced:output#ReceiveDemo_Advanced.ino).

It's not from codebender. They just have copies of a bunch of Arduino library examples on their website. The origin is here:

I have copied a sketch exactly as given from someone in arduino.

As others have mentioned, you only have a fragment of a complete program. This is an example sketch of the "rc-switch" library. The easiest way to get the full program is to install the library via Library Manager (if you haven't already):

  • Sketch > Include Library > Manage Libraries
  • Wait for the update to finish.
  • In the "Filter your search" field, type "rc-switch".
  • Press Enter.
  • From the list of search results, click on "rc-switch by sui77".
  • Click the "Install" button.
  • Wait for the installation to finish.
  • Click the "Close" button.

Now that you have installed the library, the complete "ReceiveDemo_Advanced" example sketch is accessible via the File > Examples > rc-switch > ReceiveDemo_Advanced menu.

I had done all the 8 steps but hadn't found the rc switch in examples. Now I have found it right down the bottom and in the extension box also 'receive demo advanced'. So I guess it will work now with no query about defining 'output'. The only difference between the original seems to be the addition of 'receive demo advanced'.
My title for the sketch was 'decode and send 433mhz rf signals'. the new title from looking up examples is 'receive demo advanced'. Apart from that the coding is exactly the same. I therefore still have doubts if it is going to compile properly but I will give it a go now and get back to you.

The sketch' rc switch receive demo advanced' now compiling ok. Now not apparently receiving any signal from the receiver module. Nothing on the serial monitor. It is a 433mhz rxn3-b from jaycar. It actually says its for 434mhz and 315mhz. Used a transmitter signal from a remote mains appliance transmitter and also my car remote.
Everything seems to be connected ok. Puzzled by the apparent connection of the antenna terminal to ground. That doesn't seem right. I am using the same 5v and ground connections to rxn3-b as my nano board.
The rxn3-b uses ook. Wait a minute. That is on/off keying of the 433mhz signal. If the transmitter uses a different keying there will be no match. The car or mains appliance remote may be using 'ask' or 'fsk' keying. Am I right?
Just another thing. How can I get email notifications when there is a reply to my post? 'all about circuits' do this.


How can I get email notifications when there is a reply to my post?

You take your chances with that facility.
Forget about notifications and just log on when you can.
Many have it turned on, but it only works in my case when there is a blue moon with a cow jumping over it.

Tom... :slight_smile:

I find it to be quite reliable. I use email notifications exclusively for using this forum. I never browse it. I know the forum's native "Alerts" system (the tab at the top of the web page) has issues from time to time, but those issues don't appear to affect the email notifications.

However, at least when I joined the forum, they are disabled by default and the configuration page is a little confusing.

Here's how you can configure the notification settings:

  • Hover the mouse pointer over your avatar in the top right corner of any arduino.cc page.
  • Click "Profile".
  • Click "Forum Settings > Edit".
  • Click the "Settings" tab.
  • Click "Notifications".
  • Configure the notifications to your preferences. Note there is a tricky thing. The first two checkboxes under the "Alert Preferences" section apply to the description below the checkbox.
  • Click the "Save settings" button.