LED Output Different When Powered by USB vs 12V

Hey everyone. I’ve got about 80 GRB LEDs that I’m controlling with a Nano. I have a simple routine that uses a rotary encoder and interrupts to change the lights from white to soft yellow (my wife is going to use the lights for a studio box).

When I plug the Arduino into my computer via the USB port, it works exactly as expected, however, when I use a 12V adapter through the VIN, all the lights turn an ugly yellow, and are not uniform in color as they are when powered through the USB.

I understand that the recommended voltage range that the Arduino’s voltage regulator can handle is 7-12V, so that shouldn’t be a problem – is there anything I’m missing here that would make it act like this?

TIA

Here is the code if needed for reference. It’s not very professional, I’m warning you in advance:

#include <Adafruit_NeoPixel.h>
#define PIN        5
#define NUMPIXELS 80
#define BRIGHTNESS 100
#define inputDT 3
#define inputSW 2
#define inputCLK 4
Adafruit_NeoPixel strip(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);


int brightness = BRIGHTNESS;
unsigned long timesincebutt;
int currentStateCLK;
int previousStateCLK;
int counter =0;
String encdir="";

int red = 255;
int green = 255;
int blue = 255;

/////////////////////////////////////////////////////////////////////////////////////////////////////
// SETUP   SETUP   SETUP   SETUP   SETUP   SETUP   SETUP   SETUP   SETUP   SETUP   SETUP   SETUP   //
/////////////////////////////////////////////////////////////////////////////////////////////////////

void setup() {
  // put your setup code here, to run once:
  pinMode(inputSW, INPUT_PULLUP);
  pinMode(inputCLK, INPUT);
  pinMode(inputDT, INPUT);
  Serial.begin(9600); // initialize serial communications at 9600 bps
  strip.begin();
  strip.show();
  strip.setBrightness(brightness);
  previousStateCLK=digitalRead(inputCLK);
  attachInterrupt(digitalPinToInterrupt(inputSW), updateButton, LOW);
  attachInterrupt(digitalPinToInterrupt(inputDT), update, CHANGE);
  timesincebutt=millis();
}

/////////////////////////////////////////////////////////////////////////////////////////////////////
// LOOP   LOOP   LOOP   LOOP   LOOP   LOOP   LOOP   LOOP   LOOP   LOOP   LOOP   LOOP   LOOP   LOOP //
/////////////////////////////////////////////////////////////////////////////////////////////////////

void loop() {
  setStrip(red, green, blue);
  strip.setBrightness(brightness);
  strip.show();
}

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//   ISR      ISR      ISR      ISR      ISR      ISR      ISR      ISR      ISR      ISR      ISR      ISR      //
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////

void updateButton(){
  brightness+=10;
  red = 0;
  if(brightness > 250){
    brightness = 10;
  }
}

void update(){
  // Interrupt to check on the encoder
  currentStateCLK = digitalRead(inputCLK);
  if (currentStateCLK != previousStateCLK){
    if (digitalRead(inputDT) != currentStateCLK){
      // enc would normally be going up, but because of the interrupt pin configuration, up and down are swapped.
      // enc is going down
      counter--;
      encdir="CW"; 
      //What that thang do
      if(blue > 5){
        blue-=5;
//        red-=5;
//        green-=5;
      }
    }else{
      //enc is going up
      counter++;
      encdir="CCW";
      //What that thang do
      if (blue<250){
        blue+=5;
//        green+=5;
//        red+=5;
      }
    }
  }
  previousStateCLK=currentStateCLK;  
}


void setStrip(int red, int green, int blue){
  //Use red, green, and blue to update every pixel in the strip
  for (int i=0;i<NUMPIXELS;i++){
    strip.setPixelColor(i, strip.Color(red, green, blue));
  }
  strip.show();
  return;
}

12v is the max input voltage is suitable that voltage is below 9v. try it
LFRED

Show us a good schematic of your circuit.

Show us a good image of your ‘actual’ wiring.

Give links to components.

Unfortunately, you have been sadly misled by the outdated information on the Arduino site proper and various “tutorials”.

The clear blunder is not comprehending what the “Vin” or “RAW” terminal is. The regulator on the Arduino UNO/ Nano/ Pro Mini/ Mega2560/ Leonardo/ Pro Micro has very little heatsink, so will not pass very much current (depending on the input voltage and thus, how much voltage it has to drop) before it overheats and (hopefully reversibly) shuts down. It is essentially little more than a novelty provided in the very beginning of the Arduino project when “9V” power packs were common and this was a practical way to power a lone Arduino board for initial demonstration purposes. And even then it was limited because an unloaded 9 V transformer-rectifier-capacitor supply would generally provide over 12 V which the regulator could barely handle.

Nowadays, 5 V regulated switchmode packs are arguably the most readily available in the form of “Phone chargers” and switchmode “buck” regulators to regulate down from 12 V or other available voltages are cheap on eBay so these can be fed into the USB connector or (more appropriately) 5 V pin to provide adequate power for most applications. Unfortunately, many tutorials or “instructables” are seriously outdated or misleading and have not been updated to reflect the contemporary situation.

Thus far, we have no idea how you are powering the LEDs, so without that information we cannot begin to advise on how to proceed. :astonished: