Pixie Brightness and setColor

EL Wire/Tape/Panels, LEDs, pixels and strips, LCDs and TFTs, etc products from Adafruit

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
sparkes
 
Posts: 3
Joined: Sat Jul 02, 2022 2:07 pm

Pixie Brightness and setColor

Post by sparkes »

Hello, I just picked up some pixies to make some RGB programmable light fixtures on a small scale. I wired up a pixie, and used the included library's strandtest, as well as written some of my own code, but I find that something isn't going as intended. I have read through the library, and realize that setBrightness can take a 0 argument for no brightness adjustment, but it seems like I can call strip.setBrightness(1) and strip.setBrightness(255) with no apparent difference. I've tried calling show after each setBrightness call to no avail, I've tried starting at 1 brightness and for looping and delaying my way up to higher brightnesses, but even with debug output dumping to the serial monitor, I'm not noticing any difference in brightness.

Am I missing something regarding brightness? I feel like something else is going on, as when I upload the code, I do not get a R led, then G, then B as the setup shows, I get blue/green and then it seemingly is giving off incorrect colors. Did I short something out or confuse something somewhere?

Included is my code, and some shots of solder joints and configuration. edit: files were too big for forum, pics and vid here: https://imgur.com/a/Rrqwdk7

Below is my mildly modified strandtest: I have changed the rainbow color changing to set it to straight red for testing

Code: Select all

/*
  Pixie reads data in at 115.2k serial, 8N1.
  Byte order is R1, G1, B1, R2, G2, B2, ... where the first triplet is the
  color of the LED that's closest to the controller. 1ms of silence triggers
  latch. 2 seconds silence (or overheating) triggers LED off (for safety).

  Do not look into Pixie with remaining eye!
*/

#include "Adafruit_Pixie.h"

#if (defined(__AVR__) || defined(ESP8266)) && !defined(__AVR_ATmega2560__)
// For UNO and others without hardware serial, we must use software serial...
// Set up the serial port to use softwareserial..

#include "SoftwareSerial.h"
#define PIXIEPIN  6 // Pin number for SoftwareSerial output
SoftwareSerial pixieSerial(-1, PIXIEPIN);

#else
// On Leonardo/M0/etc, others with hardware serial, use hardware serial!
// #0 is green wire, #1 is white
#define pixieSerial Serial1

#endif

#define NUMPIXELS 1 // Number of Pixies in the strip
Adafruit_Pixie strip = Adafruit_Pixie(NUMPIXELS, &pixieSerial);
// Alternately, can use a hardware serial port for output, e.g.:
// Adafruit_Pixie strip = Adafruit_Pixie(NUMPIXELS, &Serial1);

void setup() {
  int i;

  Serial.begin(9600);
  Serial.println("Ready to Pixie!");

  pixieSerial.begin(115200); // Pixie REQUIRES this baud rate
  // Serial1.begin(115200);  // <- Alt. if using hardware serial port

  strip.setBrightness(2);  // Adjust as necessary to avoid blinding

  Serial.println("Red!");
  for(i=0; i< NUMPIXELS; i++)
    strip.setPixelColor(i, 255, 0, 0);
  strip.show();
  delay(1000);

  Serial.println("Green!");
  for(i=0; i< NUMPIXELS; i++)
    strip.setPixelColor(i, 0, 255, 0);
  strip.show();
  delay(1000);

  Serial.println("Blue!");
  for(i=0; i< NUMPIXELS; i++)
    strip.setPixelColor(i, 0, 0, 255);
  strip.show();
  delay(1000);
}

void loop() {
  Serial.println("Rainbow!");
  rainbowCycle(20);
}


// 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< NUMPIXELS; i++) {
      
      strip.setPixelColor(i, 255,0,0);
    
      //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) {
  if(WheelPos < 85) {
   return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
  } else if(WheelPos < 170) {
   WheelPos -= 85;
   return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
  } else {
   WheelPos -= 170;
   return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
  }
}

And if it may prove useful, here is my existing code that I will be running when I get the pixie sorted out:

Code: Select all

// All potentiometer analog pins have value: 0 - 1023
#define PIN_CHAN1_R A0
#define PIN_CHAN1_G A1
#define PIN_CHAN1_B A2
#define PIN_CHAN1 A3

#define PIN_PIXIE_1 6

#define BRIGHTNESS 1
#define SLEEPTIME 100
#define NUMPIXELS 1

#include "Adafruit_Pixie.h"


#if (defined(__AVR__) || defined(ESP8266)) && !defined(__AVR_ATmega2560__)
// For UNO and others without hardware serial, we must use software serial...
// Set up the serial port to use softwareserial..

#include "SoftwareSerial.h"

SoftwareSerial pixieSerial(-1, PIN_PIXIE_1);

#else
// On Leonardo/M0/etc, others with hardware serial, use hardware serial!
// #0 is green wire, #1 is white
#define pixieSerial Serial

#endif

Adafruit_Pixie pixie1 = Adafruit_Pixie(1, &pixieSerial);

void setup()
{
  int i;

  Serial.begin(9600);
  Serial.println("Ready to Pixie!");

  pixieSerial.begin(115200); // Pixie REQUIRES this baud rate
  // Serial1.begin(115200);  // <- Alt. if using hardware serial port

  pixie1.setBrightness(2);  // Adjust as necessary to avoid blinding

  Serial.println("Red!");
  for(i=0; i< NUMPIXELS; i++)
    pixie1.setPixelColor(i, 255, 0, 0);
  pixie1.show();
  delay(1000);

  Serial.println("Green!");
  for(i=0; i< NUMPIXELS; i++)
    pixie1.setPixelColor(i, 0, 255, 0);
  pixie1.show();
  delay(1000);

  Serial.println("Blue!");
  for(i=0; i< NUMPIXELS; i++)
    pixie1.setPixelColor(i, 0, 0, 255);
  pixie1.show();
  delay(1000);
}

void loop()
{
  int chan1_brightness = map(analogRead(PIN_CHAN1), 0, 1023, 0, 255);
  int chan1_brightness_percent = map(chan1_brightness, 0, 255, 0, 100);

  // all analogRead values from the pots will be 0-1023, and the LEDs need 0-255, so we (ab)use map
  int chan1_R = map(analogRead(PIN_CHAN1_R), 0, 1023, 0, 255);
  int chan1_G = map(analogRead(PIN_CHAN1_G), 0, 1023, 0, 255);
  int chan1_B = map(analogRead(PIN_CHAN1_B), 0, 1023, 0, 255);
  
  pixie1.setBrightness(chan1_brightness);
  pixie1.setPixelColor(0, chan1_R, chan1_G, chan1_B);

  pixie1.show();

  char buffer[100];
  sprintf(buffer, "Ch1 (%d): 0x %X %X %X", chan1_brightness, chan1_R, chan1_G, chan1_B);
  Serial.println(buffer);

  delay(SLEEPTIME);

}

// 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 < 1; i++) {
      pixie1.setPixelColor(i, Wheel(((i * 256 / pixie1.numPixels()) + j) & 255));
    }
    pixie1.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) {
  if (WheelPos < 85) {
    return pixie1.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
  } else if (WheelPos < 170) {
    WheelPos -= 85;
    return pixie1.Color(255 - WheelPos * 3, 0, WheelPos * 3);
  } else {
    WheelPos -= 170;
    return pixie1.Color(0, WheelPos * 3, 255 - WheelPos * 3);
  }
}
Any help or guidance is much appreciated, I didn't seem to find much about brightness or color for the Pixie.

User avatar
mikeysklar
 
Posts: 13936
Joined: Mon Aug 01, 2016 8:10 pm

Re: Pixie Brightness and setColor

Post by mikeysklar »

It's hard for me to tell from the photos, but thank you for providing them along with the example code.

Are you connecting to the Pixie "In" side of the board?

viewtopic.php?f=51&t=191682&p=927341&hi ... ie#p927341

Can you clean up the soldering and a bit on the pixie?

User avatar
sparkes
 
Posts: 3
Joined: Sat Jul 02, 2022 2:07 pm

Re: Pixie Brightness and setColor

Post by sparkes »

In the picture of the backside of the pixie, you can just barely make out the "out" on the far side of the board. They are indeed on the in side, and my wires are clearly attached to positive and negative.

I have one more pixie that I'll solder up and see if I see the same behavior. I have another fresh nano as well. Will report back.

Edit: it also occurred to me that I have not grounded my pixie. Perhaps my problem relates to the lack of grounding causing interference on the data line? I used a 26g piece of twisted pair wir for the data line, perhaps the insulation is insufficient? It's also solid core, which I'm less familiar with.

Thank you for your reply!

User avatar
sparkes
 
Posts: 3
Joined: Sat Jul 02, 2022 2:07 pm

Re: Pixie Brightness and setColor

Post by sparkes »

I just did a stupid move. After wiring ground on the Arduino and the negative lead to the pixie, I have no more erratic behavior, and my mini RGB mixer dimmer is working as intended! Leaving answer here for anyone else who made a dumb bonehead move and forgot to ground the pixie when using external power supply!

User avatar
mikeysklar
 
Posts: 13936
Joined: Mon Aug 01, 2016 8:10 pm

Re: Pixie Brightness and setColor

Post by mikeysklar »

Thank you for the followup. Glad it was just a shared GND issue.

Locked
Please be positive and constructive with your questions and comments.

Return to “Glowy things (LCD, LED, TFT, EL) purchased at Adafruit”