NEED A FRESH SET OF EYES
I'm Build an 10 Chanel transmitter from a video Cheep Ass Quadcopter
I have Been working on Transmitter this for several months I'm having a rough time getting the 2 pots to work.
The Pots read as if one is stuck or at times they both work as if they are on the same pins reading the same values.
All 4 of my switches work
Replaced the Pots with new ones and Changed Analog Pin location 4,5,6,7 with no change thats why i think the hardware is ok.
I'm using a very new version of Arduino and nRF24L01 and they work everywhere else sketch wise that is.
I also removed constrain from the Pots in the sketch also no change
I will build a new Tester Thingy with 3V Arduino and A new Arduino for the Transmitter if you recommend
below is the sketch..
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
const uint64_t pipeOut = 0xE8E8F0F0E1LL;
RF24 radio(9, 10);
// The sizeof this struct should not exceed 32 bytes
struct MyData {
byte throttle;
byte yaw;
byte pitch;
byte roll;
byte dial1;
byte dial2;
byte switches; // bitflag
};
MyData data;
void resetData()
{
data.throttle = 0;
data.yaw = 127;
data.pitch = 127;
data.roll = 127;
data.dial1 = 0;
data.dial2 = 0;
data.switches = 0;
}
void setup()
{
radio.begin();
radio.setAutoAck(false);
radio.setDataRate(RF24_250KBPS);
radio.openWritingPipe(pipeOut);
resetData();
}
/************************************************/
// Returns a corrected value for a joystick position that takes into account
// the values of the outer extents and the middle of the joystick range.
int mapJoystickValues(int val, int lower, int middle, int upper, bool reverse)
{
val = constrain(val, lower, upper);
if ( val < middle )
val = map(val, lower, middle, 0, 128);
else
val = map(val, middle, upper, 128, 255);
return ( reverse ? 255 - val : val );
}
void loop()
{
boolean mode1 = false;//!digitalRead(4);
// The calibration numbers used here should be measured
// for your joysticks using the TestJoysticks sketch.
data.throttle = mapJoystickValues( analogRead(A0), 180, 482, 807, false );
data.yaw = mapJoystickValues( analogRead(A1), 150, 490, 800, true );
data.pitch = mapJoystickValues( analogRead(A2), 220, 468, 800, false );
data.roll = mapJoystickValues( analogRead(A3), 225, 487, 850, true );
data.dial1 = constrain( map( analogRead(A4), 1, 1020, 0, 255 ), 0, 255);
data.dial2 = constrain( map( analogRead(A5), 1, 1020, 0, 255 ), 0, 255);
data.switches = 0;
if ( ! digitalRead(2) ) data.switches |= 0x1;
if ( ! digitalRead(3) ) data.switches |= 0x2;
if ( ! digitalRead(4) ) data.switches |= 0x4;
if ( ! digitalRead(5) ) data.switches |= 0x8;
radio.write(&data, sizeof(MyData));
}