Receiver.h is a library for the Arduino Uno or any application using the ATmega328P or register-compatible chip clocked at 16MHz.
Here, the outputs from the receiver are shown on a logic analyzer, and this is what the included arduino example MultipleChannelRead outputs for the same pulses:
0: 1481 1: 1480 2: 984 3: 1486 4: 1987 5: 0Due to there only being two external interrupts available, the library instead uses pin change interrupts on PD2-PD7 (PCINT 18-23).
The library uses Timer/Counter1, with a prescaler of 8. If you change this, Receiver.h will not work.
Arduino uses Timer/Counter0 for millis(), micros() and delay(), so these functions can still be used together with this.
When a pinchange is detected on PD2-PD7, the pin is read, if it is HIGH, the current value of Timer1 is written to a temporary variable. Following the HIGH change, there should be a LOW one. When a LOW change is detected, the current timer value is read, and then the old timer value is subtracted from it. This gives us our pulsewidth.
The time in microseconds is read by reading the value of TCNT1. With a clock of 16Mhz and a prescaler of 8, the timer clocks at 2 * 10^6 µS, two pulses per microsecond.
If this value then is right-shifted one step, we get a timestamp in microseconds.
You can only use analogWrite on PB3 (Arduino pin 11) while using this library. This is due to the other pins/timers being occupied. In the future I might write a software PWM compatible with Receiver.h, however right now your options are limited unless you write something of your own.
The library is currently in version 0.1, the basics work, however, at present time you can not configure the amount of pins, meaning that PD2 to PD7 can not be used for other purposes.
Also, when the timer overflows, the value of the channel isn't updated, this could possibly cause problems for applications where a very high refresh rate is needed.
This will be fixed in a future release.
It is in my (somewhat biased) opinion very easy to use, and included in the .zip file for Arduino there are three examples. SingleChannelRead, MultipleChannelRead and ControlSingleLED.
First, you initializeReceiverDecoder(), then you simply read a channel by calling the getStickValue(n) function, where n is a number between 0 (PD2) and 5 (PD7).
Unzip the archive into arduino_dir/libraries
Download Receiver.h v0.1