4
// This software is intended to be run on a small Arduino (e.g., a Pro Mini),
5
// whose purpose is dedicated to talking to the RC system. That is to say, it
6
// listens to the PPM signal from the RC receiver and produces a compatible
7
// single for the ESCs to control the motors. It additionally talks to the main
8
// board via a trivial serial protocol. In so doing, this software relieves the
9
// main board (and software running on it) of the task of interfacing with any
15
// The 8 channels (from the RC receiver) need to be combined and fed to two
16
// interrupts on the Arduino. They need to be combined in such a way as to
17
// alternate pulses between the two interrupts (which are alternately used to
18
// read the pulses). Like this:
20
// ch1 ch3 ch5 ch7 ch2 ch4 ch6 ch8
24
// ___ | | | | | | | | ___
25
// GND ---|___|---+----+----+----+ +----+----+----+----|___|--- GND
27
// ____________________ | __ | _____________________
30
// (interrupt 0) (interrupt 1)
32
// The two resistors in the circuit are pull-down resistors (so, say 100kΩ).
33
// Without them, the Arduino is unable to read the pulse wave at all.
35
// Note that your receiver may not send pulses sequentially, in "channel order".
36
// If this turns out to be the case, you will need to arrange for the pulses to
37
// wire up the channels in an order whereby the pulses alternatively alternately
38
// between the two interrupts and adjust the channel order below.
59
pinMode( LED_PIN, OUTPUT );
60
digitalWrite( LED_PIN, LOW );
66
static bool on = false;
68
digitalWrite( LED_PIN, on? HIGH : LOW );
74
int channel_values[ NUM_CHANNELS ];
78
// have we read a whole set of channel values?
79
if( Receiver::read_channels( channel_values ) )
84
// send channel values to main board
85
Comms::write_channels( channel_values );
88
Motors::set_values( channel_values );