That code is a horrible mess makes seeing what you are doing very difficult.
In this section
//leftLED
if ((ypr[2] * 180 / M_PI) < -20)
{
digitalWrite(rightLED, LOW);
digitalWrite(leftLED, HIGH);
// roll = (ypr[2] * 180 / M_PI);
// roll = 254;
roll = 153;
pitch = 153/2;
}
//rightLED
if ((ypr[2] * 180 / M_PI) > 20)
{
digitalWrite(rightLED, HIGH);
digitalWrite(leftLED, LOW);
// roll = -(ypr[2] * 180 / M_PI);
// roll = 0;
roll = 0;
// pitch = 153/2;
}
//middle
if (ypr[2] * 180 / M_PI >= -20 && ypr[2] * 180 / M_PI <= 20)
{
digitalWrite(rightLED, LOW);
digitalWrite(leftLED, LOW);
// roll = 254/2;
roll = 153/2;
// pitch = 153/2;
}
There seems to be a stray reference to your pitch variable. This is when I stopped looking into it, my brain hurts and it's nap time. This is the kind of thing you should be looking for and finding and fixing.
I am not able to untangle left, right, up, down, neutral, pitch and roll. And right now, you are sending nothing but the 0, middle and maximum values…
All those comments, my goodness, I couldn't read or search within your code for where you were actually doing anything until I stripped them out with my editing tool!
I suggest you write a very smaller and simple program that simply seeks to answer the basic question: can you send analog values to the transmitter board and have them cause the same response as the joysticks.
Just a loop writing values slowly from 0 to 3 volts (169) and back down on one axis holding the other at 85. Over and over.
OBSERVE the voltage going to the microprocessor.
Then do the same thing for the other axis.
I think you will find that you now have a giant software headache. I am quite confident that you have successfully hacked into the transmitter board in terms of hardware, but it should be proven or proceeding will be wasteful of time.
And WTF is this
teapotPacket[2] = fifoBuffer[0];
all about? You should clean up your code to get rid of all the junk you dragged in from where ever you borrowed it from.
a7