Can anyone tell me if it is possible to send data through the analogue pins of the Ardupilot to the analog pins of the Arduino? For example, I would like to trigger a button on a channel from my radio control and Ardupilot should send a specific number to the Arduino. Would anyone have any idea how I can do this? Thank you in advance.
$\begingroup$ You could use the servo pinouts for the camera/ additional sensor for this. You would need to map the pulse corresponding to your "trigger" on the transmitter to a specific value on the Arduino. This is pretty simple, come to think of it- you are sending a servo signal from the Ardupilot and receiving it on the Arduino. $\endgroup$– sg_robsNov 20, 2016 at 7:48
The best way to achieve this would be with RC channel pass through, you can configure any channel from 7-14 for RC passthrough (technically you can configure lower channels for this but this can cause weird things to happen as they might be sharing your pitch/roll/yaw/throttle/mode setting) You can then read in the servo value on the arduino with the pulseIn function, Ideally the servo output should be very accurate but for robustness I would have 10 µs ranges, allowing you to have over 100 unique outputs. As a bonus you can use the Do_Set_Servo command using pre programmed missions to activate your arduino at specific waypoints.
Specific number? no. there will be some inaccuracy.
Also note that your servo output is a period of time at high voltage, then a long gap at ground. So if you just use analogRead then you will only ever get high or low value (seemingly at randomly as your Arduino and ardupilot drift in and out of phase). You would have to (unless there already exists a library) time the ms the channel stays high for. Or you could try and smooth this signal with a capacitor and use analogRead as normal (very inaccurate BTW, but could easily determine an on/off signal from a transmitter).
Alternatively, use I2C, this will allow you to send precise data between your 2 devices. But you will have to find out how to instruct your Ardupilot on what to send over the I2C bus.