Thanks for your answer, that might have become a problem in the future, but in this case it still doesn´t work; the program still returns "connection failed".
I thought about it as maybe being a hardware issue, I´m actually using clones ("Funduino").
Is there some way to find out whether the Arduinos do communicate with the modules correctly?
And does anyone know what exacly the function myswitch.available() does?
It tells you the number of characters waiting to be processed from the stream "myswitch". A stream can be various things like the serial monitor, a file on an SD card, or, in this case, received from the transmitter.
if (mySwitch.available())
works because zero is interpreted as false and any other value is interpreted as true, because that's the way C code works.
If there are zero characters waiting, that could mean nothing has been received because the receiver circuit isn't working, or because nothing has been transmitted, because the transmitter circuit is not working. What you need to figure out, as you have already realised, is which is those two things it is.
It's rare that using clones is the reason that something doesn't work. Arduino hardware is "open source", so the cloners don't have to struggle to figure out how the original/genuine Arduino board works, they are free to copy the published schematics perfectly legally.
It can happen, of course. There was a brand of "clones" a little while ago that did not use genuine AVR chips in their Unos/Nanos. These caused a lot of problems. Instead they used chips that had been designed to replicate the operation of genuine AVR chips. AVR chips are not open source, so the replica chips, inevitably, were unable to behave 100% identically to the genuine chips.
I have at least one Funduino Nano. It uses a genuine AVR chip and has always performed perfectly.
Ok, I tried to use the example sketches, unfortunally still doesn´t work, but I found out something interesting.
I´m now using these sketches:
Transmitter:
You see, all the data is 0 or not available, except the raw data, where I get an output that is most of the time somewhere between 3200 and 3420 .
For some reason some numbers are more likely to come as an output than others, I don´t know if that is important.
But if I deactivate the transmitter, the raw data output are completely random numers, most of the time between 100 and 10000 (but still only one number per incoming data block).
I have now idea what this does mean (except that there is some kind of communication between transmitter and receiver), can anyone make sense out of that?