Invalid use of void expression

I’m working on a code for light up shoes and I’m using an if, else statement, but it’s telling me that I have an invalid use of void expression when I use it. Any suggestions?

Here’s my code:

const int analogPin = A2; // pin that the sensor is attached to
const int ledStrip = 2; // pin that the LED is attached to
const int threshold = 600; // an arbitrary threshold level that’s in the range of the analog input
#include <Adafruit_NeoPixel.h>
#include <avr/power.h>

#define PIN 2

#define NUMPIXELS 17

Adafruit_NeoPixel strip = Adafruit_NeoPixel(60, PIN, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);

// Slightly different, this makes the rainbow equally distributed throughout
void rainbowCycle(uint8_t wait) {
uint16_t i, j;

for(j=0; j<256*5; j++) { // 5 cycles of all colors on wheel
for(i=0; i< strip.numPixels(); i++) {
strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + j) & 255));
}
strip.show();
delay(wait);
}
}

// Input a value 0 to 255 to get a color value.
// The colours are a transition r - g - b - back to r.
uint32_t Wheel(byte WheelPos) {
WheelPos = 255 - WheelPos;
if(WheelPos < 85) {
return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
} else if(WheelPos < 170) {
WheelPos -= 85;
return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
} else {
WheelPos -= 170;
return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
}
}

void setup() {
// initialize the LED pin as an output:
pinMode(ledStrip, OUTPUT);
// initialize serial communications:
// initialize serial communications:
Serial.begin(9600);
strip.begin();
strip.show(); // Initialize all pixels to ‘off’
}

void loop() {
// read the value of the potentiometer:
int analogValue = analogRead(analogPin);

if (analogValue > threshold)
{
digitalWrite(ledStrip, rainbowCycle(20));
}
else
{
for(int i=0;i<NUMPIXELS;i++)
{
digitalWrite(ledStrip, pixels.setPixelColor(i, pixels.Color(0,150,0)));
}
}

// print the analog value:
Serial.println(analogValue);
delay(1); // delay in between reads for stability
}

Do a CTRL-T, autoformat, and check your pairs of { }.
I think you have a } in the wrong place somewhere.

void rainbowCycle(uint8_t wait)

The rainbowCycle() function is declared void, ie it does not return a value but here

digitalWrite(ledStrip, rainbowCycle(20));

you are expecting it to return a value.

try this, might be working (not tested)

const int analogPin = A2;    // pin that the sensor is attached to
const int ledStrip = 2;       // pin that the LED is attached to
const int threshold = 600;   // an arbitrary threshold level that's in the range of the analog input
#include <Adafruit_NeoPixel.h>
#include <avr/power.h>

#define PIN 2

#define NUMPIXELS      17

Adafruit_NeoPixel strip = Adafruit_NeoPixel(60, PIN, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);


// Slightly different, this makes the rainbow equally distributed throughout
void rainbowCycle(uint8_t wait) {
    uint16_t i, j;

    for(j=0; j<256*5; j++) { // 5 cycles of all colors on wheel
        for(i=0; i< strip.numPixels(); i++) {
            strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + j) & 255));
        }
        strip.show();
        delay(wait);
    }
}

// Input a value 0 to 255 to get a color value.
// The colours are a transition r - g - b - back to r.
uint32_t Wheel(byte WheelPos) {
    WheelPos = 255 - WheelPos;
    if(WheelPos < 85) {
        return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
    } else if(WheelPos < 170) {
        WheelPos -= 85;
        return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
    } else {
        WheelPos -= 170;
        return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
    }
}


void setup() {
    // initialize the LED pin as an output:
    pinMode(ledStrip, OUTPUT);
    // initialize serial communications:
    // initialize serial communications:
    Serial.begin(9600);
    strip.begin();
    strip.show(); // Initialize all pixels to 'off'
}

void loop() {
    // read the value of the potentiometer:
    int analogValue = analogRead(analogPin);

    if (analogValue > threshold)
    {
        rainbowCycle(20);  // <<<<<<<<<<<<<<<< changed
    } 
    else
    {
        for(int i=0;i<NUMPIXELS;i++)
        {
            digitalWrite(ledStrip, pixels.setPixelColor(i, pixels.Color(0,150,0))); 
        }
    }

    // print the analog value:
    Serial.println(analogValue);
    delay(1);        // delay in between reads for stability
}

Welcome to the Forum. Please read Nick Gammon’s two posts at the top of this Forum for guidelines on how to get the most out of it. Especially note the use of code tags ("</>") when posting code.