Funduino Joystick Shield Problem

Hello, I am new to this forum.
I am trying to write the transmitter code for a controller using a Funduino Joystick Shield on a Arduino Uno

In the following code if you simply serial.print the buttonUp for instance you get what you are expecting and have a 1 with the button not pushed and a 0 with it pushed.

However, if you make an if statement for when buttonUp is high print HIGH and if it is low print low.
It will print both.

This is making it impossible to create if statements on the receiving side, because it is reading as high and low at the same time.

Any help on why I am getting both high and low, but also serial print is working fine, would be great.

Below is the code that I am using:

/* JoyStick module transceiver code

  • CONNECTIONS: nRF24L01 Modules See:
    1 - GND
    2 - VCC 3.3V !!! NOT 5V
    3 - CE to Arduino pin 9
    4 - CSN to Arduino pin 10
    5 - SCK to Arduino pin 13
    6 - MOSI to Arduino pin 11
    7 - MISO to Arduino pin 12
    8 - UNUSED

Default Button Pins:
Up - pin 2
Right - pin 3
Down - pin 4
Left - pin 5
Start - pin 6
Select - pin 7
Analog - pin 8

Analog Joystick module
GND to Arduino GND
VCC to Arduino +5V
X Pot to Arduino A0
Y Pot to Arduino A1
/-----( Import needed libraries )-----/

#include <SPI.h>
#include “nRF24L01.h”
#include “RF24.h”

#define CE_PIN 9
#define CSN_PIN 10
#define xAxis 14 // A0 for Arduino UNO
#define yAxis 15 // A1 for Arduino UNO

// NOTE: the “LL” at the end of the constant is “LongLong” type
const uint64_t pipe = 0xE8E8F0F0E1LL; // Define the transmit pipe

/-----( Declare objects )-----/
RF24 radio(CE_PIN, CSN_PIN); // Create a Radio

/-----( Declare Variables )-----/
int joystick[9]; // 9 element array holding Joystick reading and 4 buttons

int buttonUp = 2;
int buttonRight = 3;
int buttonDown = 4;
int buttonLeft = 5;
int buttonstart = 6;
int buttonselect = 7;
int buttonanalog = 8;

void setup() {

Serial.begin(9600);
radio.begin();
radio.openWritingPipe(pipe);
radio.stopListening();

//declare pinMode for all buttons and initial state
pinMode(buttonUp,INPUT_PULLUP);
pinMode(buttonRight,INPUT_PULLUP);
pinMode(buttonDown,INPUT_PULLUP);
pinMode(buttonLeft,INPUT_PULLUP);
pinMode(buttonstart,INPUT_PULLUP);
pinMode(buttonselect,INPUT_PULLUP);
pinMode(buttonanalog,INPUT_PULLUP);

digitalWrite(buttonUp,HIGH);
digitalWrite(buttonRight,HIGH);
digitalWrite(buttonDown,HIGH);
digitalWrite(buttonLeft,HIGH);
digitalWrite(buttonstart,HIGH);
digitalWrite(buttonselect,HIGH);
digitalWrite(buttonanalog,HIGH);

}

void loop() {

joystick[0] = analogRead(xAxis);
joystick[1] = analogRead(yAxis);
joystick[2] = digitalRead(buttonUp);
joystick[3] = digitalRead(buttonRight);
joystick[4] = digitalRead(buttonDown);
joystick[5] = digitalRead(buttonLeft);
joystick[6] = digitalRead(buttonstart);
joystick[7] = digitalRead(buttonselect);
joystick[8] = digitalRead(buttonanalog);

radio.write( joystick, sizeof(joystick) );
delay(20);
/*
Serial.print("X = “);
Serial.print(analogRead(xAxis));
Serial.print(” Y = “);
Serial.print(analogRead(yAxis));
Serial.print(” Up = “);
Serial.print(digitalRead(buttonUp));
Serial.print(” Right = “);
Serial.print(digitalRead(buttonRight));
Serial.print(” Down = “);
Serial.print(digitalRead(buttonDown));
Serial.print(” Left = “);
Serial.println(digitalRead(buttonLeft));
Serial.print(” start = “);
Serial.println(digitalRead(buttonstart));
Serial.print(” select = “);
Serial.println(digitalRead(buttonselect));
Serial.print(” analog = ");
Serial.println(digitalRead(buttonanalog));
*/
if (joystick[2] == HIGH);{
Serial.print (“HIGH”);
}
if (joystick[2] == LOW);{
Serial.print (“low”);
}
Serial.println (joystick[2]);

}

Lose the ;

if (joystick[2] == HIGH);{

edit: both of them :wink:

if (joystick[2] == LOW);{