Hello,
Using Duane's excellent 'Read multiple RC channel' code and need to make a few changes.
The default input pins shown here in the beginning of the code:
#define THROTTLE_IN_PIN 5 //Manual input throttle from receiver
#define STEERING_IN_PIN 6 //Manual input steering from receiver
#define AUX_IN_PIN 7 //Manual toggle between autonomous and manual mode from receiver
...are pins 5, 6 and 7.
Pin 7 or AUX_IN is a 2 position toggle on my R/C transmitter. In one position it reads about 1080 and the other position it reads about 1900.
I would like to use this toggle switch to change the input pins above by adding two more input pins for Throttle_In and Steering_In.
Doing this with an 'if' statement:
if(AUX_IN < 1350)
//keep THROTTLE_IN_PIN 5 (manual mode)
//keep STEERING_IN_PIN 6 (manual mode)
//....
Here is what I changed at the beginning of the code:
#include <PinChangeInt.h>
#include <Servo.h>
// Assign your channel in pins
#define Aut_THROTTLE_IN_PIN 3 //Autonomous input throttle from PC (ADDED this)
#define Aut_STEERING_IN_PIN 4 //Autonomous input steering from PC (ADDED this)
#define THROTTLE_IN_PIN 5 //Manual input throttle from receiver
#define STEERING_IN_PIN 6 //Manual input steering from receiver
#define AUX_IN_PIN 7 //Manual toggle between autonomous and manual mode from receiver
And where I added the 'if' statement:
void setup()
{
Serial.begin(9600);
Serial.println("multiChannels");
// attach servo objects, these will generate the correct
// pulses for driving Electronic speed controllers, servos or other devices
// designed to interface directly with RC Receivers
servoThrottle.attach(THROTTLE_OUT_PIN);
servoSteering.attach(STEERING_OUT_PIN);
servoAux.attach(AUX_OUT_PIN);
// using the PinChangeInt library, attach the interrupts
// used to read the channels
//Here is where I made some changes using the 'if' statement
PCintPort::attachInterrupt(AUX_IN_PIN, calcAux,CHANGE);
if(AUX_IN_PIN < 1350)
{
PCintPort::attachInterrupt(THROTTLE_IN_PIN, calcThrottle,CHANGE);
PCintPort::attachInterrupt(STEERING_IN_PIN, calcSteering,CHANGE);
}
if(AUX_IN_PIN > 1750)
{
PCintPort::attachInterrupt(Aut_THROTTLE_IN_PIN, calcThrottle,CHANGE);
PCintPort::attachInterrupt(Aut_STEERING_IN_PIN, calcSteering,CHANGE);
}
}
*My coding problem:
In the serial monitor I still get values (don't have input from the PC yet) no matter what position the AUX toggle switch is in.
Any suggestions or help appreciated,
t