Arduino sets value as HIGH even when nothing tells it to do so.

I am in a process of creating wireless Ledstrip controller using WS2812 strip. I use arduino mega with one button, single LED(for debugging) and NRF24L01 as the transmitter side. On the receiving side i have arduino UNO connected to WS2812 led strip, speaker and single led (for debugging). Code will be posted below.

The code should work like this:
Transmitting side button is pressed ->NRF24L01 sends to the receiving side that the button state is high -> Led strip shows green color.
When button is pressed again -> NRF24L01 sends to the receiving side that button state is low -> Led strip turns off.
Now in real life what happens is that when i press the button, transmitting side sends ledstateone as HIGH, but on the receiving side both ledstateone and ledstatetwo are HIGH. There is no command on the transmitting side that tells receiving side to set ledstatetwo as HIGH but for some reason it does that.

When button is pressed Transmitting side serial monitor says:
setting pbnew and pbold equal setting pbnew and pbold equal setting pbnew and pbold equal...
and the receiving side serial monitor says:
1show GREEN 1show RED 1show GREEN 1show GREEN 1show GREEN 1show RED 1show GREEN 1show GREEN 1show RED...

Even when i haven't yet transmitted ledstatetwo, arduino UNO for some reason thinks it's HIGH and sets the colour to red. As default ledstatetwo is set to LOW so there shouldn't be any reason for it to become HIGH and activate the RED color but somehow it does. Maybe someone can spot the issue, that causes ledstatetwo to become HIGH.

Code for the transmitting side:

// transmitting side ARDUINO MEGA
#include <FastLED.h>
#define DATA_PIN 6
#define LED_TYPE WS2812B
#define COLOR_ORDER GRB
#define NUM_LEDS 15
#define BRIGHTNESS 96
CRGB leds[NUM_LEDS];

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
RF24 radio(7, 8); // CE, CSN
const byte addresses [][6] = {"00001", "00002"};    //Setting the two addresses. One for transmitting and one for receiving

int confirmLEDleft = 2;
int delaypot = A0;
int VAL; 
int pbone = 22;
int pbtwo = 23;
int pbthree = 24;
int pbfour = 25;
int pbfive = 26;
int pbsix = 27;
int pbseven = 28;
int pbeight = 29;
int spk = 11;
boolean pbVALoneold = 0;
boolean pbVALonenew = 0;
boolean pbVALtwoold = 0;
boolean pbVALtwonew = 0;
boolean pbVALthreeold = 0;
boolean pbVALthreenew = 0;
boolean pbVALfourold = 0;
boolean pbVALfournew = 0;
boolean pbVALfiveold = 0;
boolean pbVALfivenew = 0;
boolean pbVALsixold = 0;
boolean pbVALsixnew = 0;
boolean pbVALsevenold = 0;
boolean pbVALsevennew = 0;
boolean pbVALeightold = 0;
boolean pbVALeightnew = 0;
int Ledstateone = 0;
int Ledstatetwo = 0;
int Ledstatethree = 0;
int Ledstatefour = 0;
int Ledstatefive = 0;
int Ledstatesix = 0;
int Ledstateseven = 0;
int Ledstateeight = 0;


void setup() {
  Serial.begin(9600);
  pinMode(INPUT, delaypot);
  pinMode(INPUT, pbone);
  pinMode(INPUT, pbtwo);
  pinMode(INPUT, pbthree);
  pinMode(INPUT, pbfour);
  pinMode(INPUT, pbfive);
  pinMode(INPUT, pbsix);
  pinMode(OUTPUT, spk);
  pinMode(OUTPUT, confirmLEDleft);
  radio.begin();                            //Starting the radio communication
  radio.openWritingPipe(addresses[0]);      //Setting the address at which we will send the data
  radio.openReadingPipe(1, addresses[1]);   //Setting the address at which we will receive the data
  radio.setPALevel(RF24_PA_MIN);            //You can set it as minimum or maximum depending on the distance between the transmitter and receiver. 
  radio.stopListening();
  FastLED.addLeds<LED_TYPE,DATA_PIN,COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip); // initializes LED strip
  FastLED.setBrightness(BRIGHTNESS);// global brightness
  digitalWrite(confirmLEDleft, HIGH);
  delay(300);
  digitalWrite(confirmLEDleft, LOW);
  tone(spk, 500);
  delay(100);
  noTone(spk);
  tone(spk, 700);
  delay(100);
  noTone(spk);
  tone(spk, 1000);
  delay(100);
  noTone(spk);
  delay(100); // initial delay of a few seconds is recommended
}

void loop() {
  ///////////////////////////////////////////////////////////////////////////////////////////////////////
  radio.stopListening();                               //This sets the module as transmitter
  VAL = analogRead(delaypot);                          //Read potentiometer value
  radio.write(&VAL, sizeof(VAL));                      //Sends out potentiometer value
   pbVALonenew = digitalRead(pbone);                   //Reads push button one state
   if (pbVALonenew == HIGH && pbVALoneold == LOW)      //if new state is high but old state is low then...
   {
  VAL = analogRead(delaypot);                          //Read potentiometer value
  radio.write(&VAL, sizeof(VAL));                      //Sends out potentiometer value
    if (Ledstateone == HIGH)                           //if ledstateone high then...
    {
  VAL = analogRead(delaypot);                          //Read potentiometer value
  radio.write(&VAL, sizeof(VAL));                      //Sends out potentiometer value
      Ledstateone = LOW;                               //sets ledstate to LOW
      radio.write(&Ledstateone, sizeof(Ledstateone));  //Sending data that the button state is LOW
      digitalWrite(confirmLEDleft, HIGH);
      delay(100);
      digitalWrite(confirmLEDleft, LOW);
    }
    else
    {
  VAL = analogRead(delaypot);                           //Read potentiometer value
  radio.write(&VAL, sizeof(VAL));                       //Sends out potentiometer value
      Ledstateone = HIGH;                               //Sets ledstate HIGH
      radio.write(&Ledstateone, sizeof(Ledstateone));   //Sending data that the button state is HIGH
      Serial.print("else function working");
    }
  }
  if (Ledstateone == LOW)
  {
  VAL = analogRead(delaypot);                           //Read potentiometer value
  radio.write(&VAL, sizeof(VAL));                       //Sends out potentiometer value
    radio.write(&Ledstateone, sizeof(Ledstateone));     //Transmits ledstateone state
    Serial.print("sending ledtstateone as LOW ");
  }
  if (Ledstateone == HIGH)
  {
  VAL = analogRead(delaypot);                           //Read potentiometer value
  radio.write(&VAL, sizeof(VAL));                       //Sends out potentiometer value
    radio.write(&Ledstateone, sizeof(Ledstateone));     //sends out ledstate value
    pbVALoneold = pbVALonenew;                          //sets both values equal
    Serial.print("setting pbnew and pbold equal ");
  }
}

Code for the receiving side:

//Receiving side arduino UNO
#include <FastLED.h>
#define DATA_PIN 6
#define LED_TYPE WS2812B
#define COLOR_ORDER GRB
#define NUM_LEDS 15
#define BRIGHTNESS 96
CRGB leds[NUM_LEDS];

#include <Wire.h> // For I2C
#include <LCD.h> // For LCD
#include <LiquidCrystal_I2C.h> // Added library*
//Set the pins on the I2C chip used for LCD connections
//ADDR,EN,R/W,RS,D4,D5,D6,D7
LiquidCrystal_I2C lcd(0x27,2,1,0,4,5,6,7); // 0x27 is the default I2C bus address of the backpack-see article

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
RF24 radio(9, 10); // CE, CSN
const byte addresses [][6] = {"00001", "00002"};    //Setting the two addresses. One for transmitting and one for receiving

int confirmLEDright = 2;   //led pin for debugging
int spk = 8;               //speaker pin
int VAL;                   //value that is read from potentiometer and used for delay
int Ledstateone = LOW;
int Ledstatetwo = LOW;
int Ledstatethree = LOW;
int Ledstatefour = LOW;
int Ledstatefive = LOW;
int Ledstatesix = LOW;
int Ledstateseven = LOW;
int Ledstateeight = LOW;

void setup() {
  Serial.begin(9600);
   lcd.begin (20,4); // 20 x 4 LCD module
   lcd.setBacklightPin(3,POSITIVE); // BL, BL_POL
   lcd.setBacklight(HIGH);                    //If the text is dim, check this line
   radio.begin();                           //Starting the radio communication
  radio.openWritingPipe(addresses[1]);     //Setting the address at which we will send the data
  radio.openReadingPipe(1, addresses[0]);  //Setting the address at which we will receive the data
  radio.setPALevel(RF24_PA_MIN); //You can set it as minimum or maximum depending on the distance between the transmitter and receiver. 
  radio.startListening();
  FastLED.addLeds<LED_TYPE,DATA_PIN,COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip); // initializes LED strip
  FastLED.setBrightness(BRIGHTNESS);// global brightness
  pinMode(OUTPUT, spk);
   pinMode(OUTPUT, confirmLEDright);
  digitalWrite(confirmLEDright, HIGH);
  delay(300); 
  digitalWrite(confirmLEDright, LOW);
  tone(spk, 500);
  delay(100);
  noTone(spk);
  tone(spk, 700);
  delay(100);
  noTone(spk);
  tone(spk, 1000);
  delay(100);
  noTone(spk);
}

// switches off all LEDs
void showProgramCleanUp(long delayTime) {
  for (int i = 0; i < NUM_LEDS; ++i) {
    leds[i] = CRGB::Black;
  }
  FastLED.show();
    radio.read(&VAL, sizeof(VAL));     //Reads the potentiometer value
    delay(VAL);
}

// Shifts a single pixel from the start of strip to the end.
// crgb: color of shifted pixel
// delayTime: indicates how long the pixel is shown on each LED
void showProgramShiftSinglePixel(CRGB crgb, long delayTime) {
  for (int i = 0; i < NUM_LEDS; ++i) {
    leds[i] = crgb;
    FastLED.show();
    radio.read(&VAL, sizeof(VAL));     //Reads the potentiometer value
    delay(VAL);
    leds[i] = CRGB::Black;
  }
}
// Shifts multiple pixel from the start of strip to the end. The color of each pixel is randomized.
// delayTime: indicates how long the pixels are shown on each LED
void showProgramShiftMultiPixel(long delayTime) {
  for (int i = 0; i < NUM_LEDS; ++i) { 
    for (int j = i; j > 0; --j) {
      leds[j] = leds[j-1];
    }
    CRGB newPixel = CHSV(random8(), 255, 255);
    leds[0] = newPixel;
    FastLED.show();
    radio.read(&VAL, sizeof(VAL));     //Reads the potentiometer value
    delay(VAL);
    leds[i] = CRGB::Black;
  }
}

void loop() 
{
//////////////////////////////////////////////////////////////////////////////////////////////1st color//////////
  delay(5);
  radio.startListening();                            //This sets the module as receiver 
  radio.read(&Ledstateone, sizeof(Ledstateone));     //Reads the ledstateone value
  if (radio.available() && Ledstateone == HIGH)      //If ledstateone is HIGH then show GREEN color
  {
    Serial.print(Ledstateone);
    Serial.print("show GREEN ");
    showProgramShiftSinglePixel(CRGB::Lime, 100);    //Shows the GREEN colour
  }
  
  delay(5);
  radio.read(&Ledstateone, sizeof(Ledstateone));
  if (radio.available() && Ledstateone == LOW)       //If ledstatetwo is LOW then turn off leds
  {
    Serial.print(Ledstateone);
    Serial.print("turn off Ledstateone ");
    showProgramCleanUp(2500);                        // clean up, turns off leds
  }  
  ///////////////////////////////////////////////////////////////////////////////////////////2nd color////////////////
  delay(5);
  radio.startListening();                            //This sets the module as receiver 
  radio.read(&Ledstatetwo, sizeof(Ledstatetwo));     //Reads the ledstatetwo value
  if (radio.available() && Ledstatetwo == HIGH)      //If ledstatetwo is HIGH then show RED color
  {
    Serial.print(Ledstatetwo);
    Serial.print("show RED ");
    showProgramShiftSinglePixel(CRGB::Maroon, 250);  //Shows the RED colour
  }
  delay(5);
  radio.read(&Ledstatetwo, sizeof(Ledstatetwo));
  if (radio.available() && Ledstatetwo == LOW)       //If ledstatetwo is LOW then turn off leds
  {
    Serial.print(Ledstatetwo);
    Serial.print("turn off Ledstatetwo ");
    showProgramCleanUp(2500);                        // clean up, turns off leds
  }  
}
  pinMode(INPUT, delaypot);
  pinMode(INPUT, pbone);
  pinMode(INPUT, pbtwo);
  pinMode(INPUT, pbthree);
  pinMode(INPUT, pbfour);
  pinMode(INPUT, pbfive);
  pinMode(INPUT, pbsix);
  pinMode(OUTPUT, spk);
  pinMode(OUTPUT, confirmLEDleft);

ERROR: The first argument is the pin number. The second argument is the mode. You have them reversed. The compiler didn't warn you because they are both integers.

Send all your data in one packet, probably using a struct,
or at least make the different packets distinguishable.
Anonymous sends of different data will get you in trouble (as experienced).

Reading from the radio without checking for available packets is an error.

BTW delay does not work well in communication programs.

johnwasser:
The second argument is the mode. You have them reversed

Thank You for pointing that out. I flipped them correct way now.

Whandall:
Send all your data in one packet, probably using a struct,
or at least make the different packets distinguishable.
Anonymous sends of different data will get you in trouble (as experienced).

Does that mean that instead of spamming this line:

radio.write(&Ledstateone, sizeof(Ledstateone));     //Transmits ledstateone state

at every press of a button, i would instead need to "collect" all the states (HIGH or LOW) from push buttons + potentiometer(0- 1023) and send them to the receiver as one array of data?

I would collect all data that is to be shadowed to the other station in one struct/class,
with a flag field that shows which data has been updated since the last transmission.

These packets could be sent regularly, with all zero flags, just as a keep alive measure.

A change in key state should trigger an immediate send, with the corresponding bit set.

After a successful transmit you just clear all flag bits.

It's as easy as it sounds.

Another advantage of the struct/class approach is the ability to add functions to the object.
Handy for print or setting of members with the correct the flag manipulations.

For the last couple of days I tried using struct with many unsuccessful attempts. Today i decided to forget about struct and try with only arrays. Now the red color doesn't appear when 1st button is pressed which is what i needed. However now the receiving side doesn't read potentiometer value correctly. Serial monitor on the transmitting side says:
575_setting pbnew and pbold equal 575_setting pbnew and pbold equal 575_setting pbnew and pbold equal 575_setting pbnew and pbold equal

It means that the value is 575 and is being transmitted.

Serial monitor on the receiving side says:

1show GREEN 0_0_0_0_0_0_0_0_0_0_0_0_0_0_0_0turn off Ledstateone 0_0turn off Ledstatetwo 0_0turn off Ledstateone 0_0turn off Ledstatetwo 0_1show GREEN 0_0_0_0_0_0_0_0_0_0_0_0_0_0_0_0turn off Ledstateone 0_0turn off Ledstatetwo 0_0turn off Ledstateone 0_0turn off Ledstatetwo 0_1show GREEN 0_0_0_0_0_0_0_0_0_0_0_0_0_0_0_0

The long zeroes after the word GREEN are the ''VAL'' values from the potentiometer. They should be 575 but for some reason they are 0. I tried sending the potentiometer value using different array but the values still were zero.
I will post the code in replies because of the 9000 character limit.

// transmitting side ARDUINO MEGA
#include <FastLED.h>
#define DATA_PIN 6
#define LED_TYPE WS2812B
#define COLOR_ORDER GRB
#define NUM_LEDS 15
#define BRIGHTNESS 96
CRGB leds[NUM_LEDS];

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
RF24 radio(7, 8); // CE, CSN
const byte addresses [][6] = {"00001", "00002"};    //Setting the two addresses. One for transmitting and one for receiving

int confirmLEDleft = 2;
int delaypot = A0;
int pbone = 22;
int pbtwo = 23;
int pbthree = 24;
int pbfour = 25;
int pbfive = 26;
int pbsix = 27;
int pbseven = 28;
int pbeight = 29;
int spk = 11;
boolean pbVALoneold = 0;
boolean pbVALonenew = 0;
boolean pbVALtwoold = 0;
boolean pbVALtwonew = 0;
boolean pbVALthreeold = 0;
boolean pbVALthreenew = 0;
boolean pbVALfourold = 0;
boolean pbVALfournew = 0;
boolean pbVALfiveold = 0;
boolean pbVALfivenew = 0;
boolean pbVALsixold = 0;
boolean pbVALsixnew = 0;
boolean pbVALsevenold = 0;
boolean pbVALsevennew = 0;
boolean pbVALeightold = 0;
boolean pbVALeightnew = 0;
int Ledstateone;
int Ledstatetwo;
int Ledstatethree;
int Ledstatefour;
int Ledstatefive;
int Ledstatesix;
int Ledstateseven;
int Ledstateeight;
int VAL;

int Ledstates[9]={Ledstateone, Ledstatetwo, Ledstatethree, Ledstatefour, Ledstatefive, Ledstatesix, Ledstateseven, Ledstateeight, VAL};

void setup() {
  Serial.begin(9600);
  pinMode(delaypot, INPUT);
  pinMode(pbone, INPUT);
  pinMode(pbtwo, INPUT);
  pinMode(pbthree, INPUT);
  pinMode(pbfour, INPUT);
  pinMode(pbfive, INPUT);
  pinMode(pbsix, INPUT);
  pinMode(spk, OUTPUT);
  pinMode(confirmLEDleft, OUTPUT);
  radio.begin();                            //Starting the radio communication
  radio.openWritingPipe(addresses[0]);      //Setting the address at which we will send the data
  radio.openReadingPipe(1, addresses[1]);   //Setting the address at which we will receive the data
  radio.setPALevel(RF24_PA_MIN);            //You can set it as minimum or maximum depending on the distance between the transmitter and receiver. 
  radio.stopListening();
  FastLED.addLeds<LED_TYPE,DATA_PIN,COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip); // initializes LED strip
  FastLED.setBrightness(BRIGHTNESS);// global brightness
  digitalWrite(confirmLEDleft, HIGH);
  delay(300);
  digitalWrite(confirmLEDleft, LOW);
  tone(spk, 500);
  delay(100);
  noTone(spk);
  tone(spk, 700);
  delay(100);
  noTone(spk);
  tone(spk, 1000);
  delay(100);
  noTone(spk);
  delay(100); // initial delay of a few seconds is recommended
}

void loop() {
  ///////////////////////////////////////////////////////////////////////////////////////////////////////
  radio.stopListening();                               //This sets the module as transmitter
  VAL = analogRead(delaypot);                          //Read potentiometer value
  radio.write(&Ledstates, sizeof(Ledstates));          //Sending data that the button state is LOW
   pbVALonenew = digitalRead(pbone);                   //Reads push button one state
   if (pbVALonenew == HIGH && pbVALoneold == LOW)      //if new state is high but old state is low then...
   {
  VAL = analogRead(delaypot);                          //Read potentiometer value
  radio.write(&Ledstates, sizeof(Ledstates));  //Sending data that the button state is LOW
    if (Ledstates[0] == HIGH)                           //if ledstateone high then...
    {
      Ledstates[0] = LOW;                              //sets ledstateone to LOW
      VAL = analogRead(delaypot);                      //Read potentiometer value
      radio.write(&Ledstates, sizeof(Ledstates));      //Sending data that the button state is LOW
      digitalWrite(confirmLEDleft, HIGH);
      delay(100);
      digitalWrite(confirmLEDleft, LOW);
    }
    else
    {
      Ledstates[0] = HIGH;                               //Sets ledstate HIGH
      VAL = analogRead(delaypot);                        //Read potentiometer value
      radio.write(&Ledstates, sizeof(Ledstates));        //sends out ledstate value
      Serial.print("else function working");
    }
  }
  if (Ledstates[0] == LOW)
  {
  VAL = analogRead(delaypot);                           //Read potentiometer value
  Serial.print(VAL);
  Serial.print("_");
  radio.write(&Ledstates, sizeof(Ledstates));           //sends out ledstate value
  Serial.print("sending ledtstateone as LOW ");
  }
  if (Ledstates[0] == HIGH)
  {
  VAL = analogRead(delaypot);                           //Read potentiometer value
  Serial.print(VAL);
  Serial.print("_");
  radio.write(&Ledstates, sizeof(Ledstates));           //sends out ledstate value
  pbVALoneold = pbVALonenew;                            //sets both values equal
  Serial.print("setting pbnew and pbold equal ");
  }
}
//Receiving side arduino UNO
#include <FastLED.h>
#define DATA_PIN 6
#define LED_TYPE WS2812B
#define COLOR_ORDER GRB
#define NUM_LEDS 15
#define BRIGHTNESS 96
CRGB leds[NUM_LEDS];

#include <Wire.h> // For I2C
#include <LCD.h> // For LCD
#include <LiquidCrystal_I2C.h> // Added library*
//Set the pins on the I2C chip used for LCD connections
//ADDR,EN,R/W,RS,D4,D5,D6,D7
LiquidCrystal_I2C lcd(0x27,2,1,0,4,5,6,7); // 0x27 is the default I2C bus address of the backpack-see article

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
RF24 radio(9, 10); // CE, CSN
const byte addresses [][6] = {"00001", "00002"};    //Setting the two addresses. One for transmitting and one for receiving

int confirmLEDright = 2;   //led pin for debugging
int spk = 8;               //speaker pin
int Ledstateone;
int Ledstatetwo;
int Ledstatethree;
int Ledstatefour;
int Ledstatefive;
int Ledstatesix;
int Ledstateseven;
int Ledstateeight;
int VAL;                  //value that is read from potentiometer and used for delay

int Ledstates[9]={Ledstateone, Ledstatetwo, Ledstatethree, Ledstatefour, Ledstatefive, Ledstatesix, Ledstateseven, Ledstateeight, VAL};

void setup() {
  Serial.begin(9600);
   lcd.begin (20,4); // 20 x 4 LCD module
   lcd.setBacklightPin(3,POSITIVE); // BL, BL_POL
   lcd.setBacklight(HIGH);                    //If the text is dim, check this line
   radio.begin();                           //Starting the radio communication
  radio.openWritingPipe(addresses[1]);     //Setting the address at which we will send the data
  radio.openReadingPipe(1, addresses[0]);  //Setting the address at which we will receive the data
  radio.setPALevel(RF24_PA_MIN); //You can set it as minimum or maximum depending on the distance between the transmitter and receiver. 
  radio.startListening();
  FastLED.addLeds<LED_TYPE,DATA_PIN,COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip); // initializes LED strip
  FastLED.setBrightness(BRIGHTNESS);// global brightness
  pinMode(spk, OUTPUT);
  pinMode(confirmLEDright, OUTPUT);
  digitalWrite(confirmLEDright, HIGH);
  delay(300); 
  digitalWrite(confirmLEDright, LOW);
  tone(spk, 500);
  delay(100);
  noTone(spk);
  tone(spk, 700);
  delay(100);
  noTone(spk);
  tone(spk, 1000);
  delay(100);
  noTone(spk);
}

// switches off all LEDs
void showProgramCleanUp(long delayTime) {
  for (int i = 0; i < NUM_LEDS; ++i) {
    leds[i] = CRGB::Black;
  }
  FastLED.show();
    radio.read(&Ledstates, sizeof(Ledstates));     //Reads the potentiometer value
    Serial.print(VAL);
    Serial.print("_");
    delay(VAL);
}

// Shifts a single pixel from the start of strip to the end.
// crgb: color of shifted pixel
// delayTime: indicates how long the pixel is shown on each LED
void showProgramShiftSinglePixel(CRGB crgb, long delayTime) {
  for (int i = 0; i < NUM_LEDS; ++i) {
    leds[i] = crgb;
    FastLED.show();
    radio.read(&Ledstates, sizeof(Ledstates));     //Reads the potentiometer value
    Serial.print(VAL);
    Serial.print("_");
    delay(VAL);
    leds[i] = CRGB::Black;
  }
}
// Shifts multiple pixel from the start of strip to the end. The color of each pixel is randomized.
// delayTime: indicates how long the pixels are shown on each LED
void showProgramShiftMultiPixel(long delayTime) {
  for (int i = 0; i < NUM_LEDS; ++i) { 
    for (int j = i; j > 0; --j) {
      leds[j] = leds[j-1];
    }
    CRGB newPixel = CHSV(random8(), 255, 255);
    leds[0] = newPixel;
    FastLED.show();
    radio.read(&Ledstates, sizeof(Ledstates));     //Reads the potentiometer value
    delay(VAL);
    leds[i] = CRGB::Black;
  }
}

void loop() 
{
//////////////////////////////////////////////////////////////////////////////////////////////1st color//////////
  radio.startListening();                            //This sets the module as receiver 
  radio.read(&Ledstates, sizeof(Ledstates));     //Reads the ledstateone value
  if (Ledstates[0] == HIGH)      //If ledstateone is HIGH then show GREEN color
  {
    Serial.print(Ledstates[0]);
    Serial.print("show GREEN ");
    showProgramShiftSinglePixel(CRGB::Lime, 100);    //Shows the GREEN colour
  }
  
  radio.read(&Ledstates, sizeof(Ledstates));
  if (Ledstates[0] == LOW)       //If ledstatetwo is LOW then turn off leds
  {
    Serial.print(Ledstates[0]);
    Serial.print("turn off Ledstateone ");
    showProgramCleanUp(2500);                        // clean up, turns off leds
  }  
  ///////////////////////////////////////////////////////////////////////////////////////////2nd color////////////////
  radio.startListening();                            //This sets the module as receiver 
  radio.read(&Ledstates, sizeof(Ledstates));     //Reads the ledstatetwo value
  if (Ledstates[1] == HIGH)      //If ledstatetwo is HIGH then show RED color
  {
    Serial.print(Ledstates[1]);
    Serial.print("show RED ");
    showProgramShiftSinglePixel(CRGB::Maroon, 250);  //Shows the RED colour
  }
  radio.read(&Ledstates, sizeof(Ledstates));
  if (Ledstates[1] == LOW)       //If ledstatetwo is LOW then turn off leds
  {
    Serial.print(Ledstates[1]);
    Serial.print("turn off Ledstatetwo ");
    showProgramCleanUp(2500);                        // clean up, turns off leds
  }  
}

Looking at the Tx code, the only element lf the Ledstates array that you ever update is Ledstates[0]. Is that deliberate ?

Yes. My plan is to make the first button work. After that I will add the second one. If that will work too then I will add the third and so on.

I just fixed the potentiometer issue by changing the pixel void:

void showProgramShiftSinglePixel(CRGB crgb, long delayTime) {
  for (int i = 0; i < NUM_LEDS; ++i) {
    leds[i] = crgb;
    FastLED.show();
    if(radio.available()){
    radio.read(&VAL, sizeof(VAL));     //Reads the potentiometer value
    if(VAL > 1){
    Serial.print(VAL);
    Serial.print("_");
    delay(VAL);
    leds[i] = CRGB::Black;
    }
    if(VAL <= 1){
    radio.read(&VAL, sizeof(VAL));     //Reads the potentiometer value
    Serial.print(VAL);
    Serial.print("_");
    delay(VAL);
    leds[i] = CRGB::Black;
   }
  }
 }
}

Now the code works. Thanks to everyone who helped! :slight_smile:

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.