Hi, Everyone!
I am currently building an RC Transmitter and Receiver using the RF 433mHz that is built for Arduino. What I need to do is o have the transmitter (on pin 12) get a reading from 4 analog pins which have the position of the x and y-axes on the joysticks.
Any help would be well appreciated! Thanks!
Here is what I have so far;
// The A Suffix Indicates the Joystick located on the Left-Handside on the Breadboard
// The B Suffix Indicates the Joystick located on the Right-Handside on the Breadboard
int yPositionA = A0;
int xPositionA = A1;
int yPositionB = A2;
int xPositionB = A3;
int buttonA = 1;
int buttonB = 2;
int data = 12;
void setup()
{
Serial.begin(9600);
pinMode(yPositionA, INPUT); // Following 4 will Be Set As An Input that is Analog
pinMode(xPositionA, INPUT);
pinMode(yPositionB, INPUT);
pinMode(xPositionB, INPUT);
pinMode(buttonA, INPUT); // Following 2 will Be Set As An InPut that is Digital
pinMode(buttonB, INPUT);
pinMode(data, OUTPUT); // Data will be an Output on Digital (PWM) Pin 12
}
void loop()
{
yPositionA = analogRead; //will be 0 to 1023
xPositionA = analogRead;
yPositionB = analogRead;
xPositionB = analogRead;
buttonA = digitalRead; //0 or 1
buttonB = digitalRead;
data = analogWrite(xPositionA);
data = analogWrite(xPositionB);
data = analogWrite(yPositionA);
data = analogWrite(yPositionB);
}
data = analogWrite(xPositionA);
data = analogWrite(xPositionB);
data = analogWrite(yPositionA);
data = analogWrite(yPositionB);
What are you expecting back from analogWrite (used with the wrong syntax in any case) and even if you get something back why assign it to the same variable ?
Have you looked at the examples in the IDE to see how the functions are used ?
pinMode(yPositionA, INPUT); // Following 4 will Be Set As An Input that is Analog
pinMode(xPositionA, INPUT);
pinMode(yPositionB, INPUT);
pinMode(xPositionB, INPUT);
Analog pins are, by definition, INPUT only. They do not need your help to be INPUT.
int yPositionA = A0;
int xPositionA = A1;
int yPositionB = A2;
int xPositionB = A3;
These are pin numbers, not positions.
You got nothing right in loop(), except for spelling loop correctly.
A traditional RC transmitter sends a pulse of between 1000 and 2000 microseconds for each channel with a repeats the pulses evert 20 milliseconds (allowing for about 8 channels).
To calculate the pulse width in microseconds:
int ChannelPulse[i] = map(analogRead(ChannelPin[i]), 0, 1023, 1000, 2000);
For buttons you would typically use Full On (2000 uS) for HIGH and Full Off (1000 uS) for LOW:
I am currently building an RC Transmitter and Receiver using the RF 433mHz that is built for Arduino
That is not enough information. Datasheets, parts numbers, website links please, we need to know
what you are talking about exactly. 433MHz is an ISM band, there are many dozens of modules of
different sorts for communicating on ISM bands.
[ mHz is millihertz, MHz is megahertz, but what does 9 orders of magnitude matter! ]