Potentiometer controlling LED light strip issues

Have an issue with getting the led light strip to turn on properly when pressure applied to strip potentiometer. Basically the lights flicker heaps and don’t always stay on properly. Any assistance would be appreciated.

const int SENSOR_A = A0;

const int SENSOR_B = A5;

const int BUTTON = 8;

int prevPressureA = 0;
int prevPressureB = 0;

int pressureValueA;
int pressureValueB;

const int RED_PIN = 6;
const int GREEN_PIN = 5;
const int BLUE_PIN = 3;

//0 = FALSE
int RANDOM = 1;
int OFF = 0;

void setup() {

//defining the whether a pin is an input or output

//changing the colour
//RGB_light(255, 0, 0), shortcut
void RGB_light(int red, int green, int blue) {
if (OFF == 1) {
red, green, blue = 0;
} else if (RANDOM == 1) {
red = random(200);
green = random(200);
blue = random(200);

analogWrite(RED_PIN, red);
analogWrite(BLUE_PIN, blue);
analogWrite(GREEN_PIN, green);

void colours(int colourCode) {


void loop() {
//reading the the sensor values right now
pressureValueA = analogRead(SENSOR_A);
pressureValueB = analogRead(SENSOR_B);

//checking if previous pressure is more than current pressure
if (prevPressureA < pressureValueA or prevPressureB < pressureValueB) {
RGB_light(255, 100, 0);

//resetting the light with the button
if (digitalRead(BUTTON) == HIGH) {
OFF = 1;
RGB_light(0, 0, 0);
OFF = 0;

//for the next loop, the current pressure becomes the old pressure
prevPressureA = pressureValueA;
prevPressureB = pressureValueB;


I wish you would have placed your code in code tags. Easier to read and easier to copy.

As to your problem.

  1. Are you sure of the values in your pressure readings?
  2. If Button in HIGH you shut lights off. Are you sure of the state of that button?
  3. Are you sure your button is wired correctly? See question 2.
  4. What is the point of setting the OFF Flag to 1, then to 0 after you shut down the leds? It seems pointless to me, you have a function use it, do not need that flag.

Likely the answer to questions 1-3 asked by Romonaga is "no". To change that to "yes", add some Serial.println() statements at strategic points in your code and then run the code with the Serial Monitor open so you can see what is happening.