I have a Teensy 2++ and I have tried to get my flap gauge to work with the following code:
#include <Servo.h>
Servo fmotor; // an RC Servo motor for flaps
FlightSimFloat FLAPRAT; // access to X-Plane's FLAPRAT
const int fmotorPin = 2;
long encoder_prev=0; // for detecting rotary position change
elapsedMillis inactivityTimeout;// an inactivity timeout
int previousAnalog = -100;
void setup() {
fmotor.attach(fmotorPin);
FLAPRAT = XPlaneRef("sim/flightmodel/controls/flaprat");
FLAPRAT.onChange(viewFLAPRAT);
Serial.begin(9600);
Serial.println("FLAPRAT");
}
void loop() {
FlightSim.update();
}
void viewFLAPRAT(float val)
{
int angle = val *172.0 + 0.0;
fmotor.write(angle);
Serial.print("(X-Plane) FLAPRAT = ");
Serial.println(FLAPRAT);
}
The servo hits the stop limit and then gets hot. Can you tell me what I am doing wrong. I have been fighting this for over a week now.
Thanks
#include <Servo.h>
Servo fmotor; // an RC Servo motor for flaps
FlightSimFloat FLAPRAT; // access to X-Plane's FLAPRAT
const int fmotorPin = 2;
long encoder_prev=0; // for detecting rotary position change
elapsedMillis inactivityTimeout;// an inactivity timeout
int previousAnalog = -100;
void setup() {
fmotor.attach(fmotorPin);
FLAPRAT = XPlaneRef("sim/flightmodel/controls/flaprat");
FLAPRAT.onChange(viewFLAPRAT);
Serial.begin(9600);
Serial.println("FLAPRAT");
}
void loop() {
FlightSim.update();
}
void viewFLAPRAT(float val)
{
int angle = val *172.0 + 0.0;
fmotor.write(angle);
Serial.print("(X-Plane) FLAPRAT = ");
Serial.println(FLAPRAT);
}
The servo hits the stop limit and then gets hot. Can you tell me what I am doing wrong. I have been fighting this for over a week now.
Thanks