Neopixel colour control with potentiometer help?

Hi.

I am trying to control the colour of my Neopixel strip with 3 potentiometers. I thought I could read the value of each potentiometer, change the scale down to 0 - 255 from 0 - 1024 which is the potentiometer scale.

Then input these three numbers into the colour of the pixels, each potentiometer being used for R G or B.

What happens is only one potentiometer actually affects the neopixels and that’s the first pot.

Here’s my code, I was thinking that you can have a maximum of 1 potentiometer but that’s all I can think of??

#include <Adafruit_NeoPixel.h>

#define PIN 9

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


int sensorValue = analogRead(A0);
int sensorValue2 = analogRead(A1);
int sensorValue3 = analogRead(A2);
int currentColourValue;
int currentColourValue2;
int currentColourValue3;


void setup() {
  strip.begin();
  strip.show(); // Initialize all pixels to 'off'
  
  
}

void loop() {
  
  
    
  
 currentColourValue = (255 - map( analogRead(sensorValue), 0, 1024, 0, 255 ) );
 currentColourValue2 = (255 - map( analogRead(sensorValue2), 0, 1024, 0, 255 ) );
 currentColourValue3 = (255 - map( analogRead(sensorValue3), 0, 1024, 0, 255 ) );
 
 colorWipe(strip.Color(currentColourValue, currentColourValue2, currentColourValue3), 50); // Red
 

 }

void colorWipe(uint32_t c, uint8_t wait) {
  for(uint16_t i=0; i<strip.numPixels(); i++) {
      strip.setPixelColor(i, c);
      strip.show();
      delay(10);
  }
}

Hi, you do seem to have got a bit confused!

Change:

int sensorValue = analogRead(A0);
int sensorValue2 = analogRead(A1);
int sensorValue3 = analogRead(A2);

to this:

int sensorValue = A0;
int sensorValue2 = A1;
int sensorValue3 = A2;

Paul

Thank you very much it works fine now :)

Hi. I actually need to do exactly this. How would you wire the potentiometers into the curcuit? Thanks!

newbtriestoprogram: Hi. I actually need to do exactly this. How would you wire the potentiometers into the curcuit? Thanks!

https://www.arduino.cc/en/Tutorial/AnalogReadSerial