Writing to Neopixel.

Hi, Im currently working on a project Where i have 1m 60ppm Neopixel that Im controlling with a DMX curcuit. Ive been doing a few Neopixel-projects before and havent been any issues writing static output. But now as Im trying to read the DMX-input and output a single color on a specific diode Im stuck.

This is just a short example from the code:

AnalogWrite(strip1.Color(0, 255, 0, 0), DMXSerial.read(1));

This is supposed to light the first diode in red at the same level as read from DMXSerial 1.

I need help correcting this line to make it work.

Thanks!

Perhaps you mean:

strip1.Color(0, DMXSerial.read(1), 0, 0);

or

byte red = DMXSerial.read(1);
strip1.Color(0, red, 0, 0);

Post your sketch... snippets are not enough. Explain what it is supposed to do, and what its actually doing, then there's something to go on for suggesting fixes and improvments

johnwasser:
Perhaps you mean:

strip1.Color(0, DMXSerial.read(1), 0, 0);

or

byte red = DMXSerial.read(1);

strip1.Color(0, red, 0, 0);

Ah, totally makes sense now that i see it! Thanks!

MarkT:
Post your sketch… snippets are not enough. Explain what it is supposed to do, and what its actually doing, then there’s something to go on for suggesting fixes and improvments

#include <DMXSerial.h>
#include <Adafruit_NeoPixel.h>
#define PIXEL_COUNT_OUTPUT1 60
#define PIXEL_PIN 9


Adafruit_NeoPixel strip1 = Adafruit_NeoPixel(PIXEL_COUNT_OUTPUT1, PIXEL_PIN,NEO_GRB + NEO_KHZ800); //Information about the Neopixelstrip.

void setup () {
  DMXSerial.init(DMXReceiver);

  pinMode(PIXEL_PIN,   OUTPUT); // sets the digital pin as output
  
strip1.begin(); //Start sending.
strip1.clear();
strip1.show(); //All pixels at 0.


}


void loop() {

uint32_t red = strip1.Color(255, 0, 0);
uint32_t green = strip1.Color(0, 255, 0);
uint32_t blue = strip1.Color(0, 0, 255);
uint32_t none = strip1.Color(0, 0, 0); //Just some default colors for easy access.

/*strip1.setPixelColor(0, red);
strip1.setPixelColor(1, red);
strip1.setPixelColor(2, red);
strip1.setPixelColor(3, red);
strip1.show();*/


  // Calculate how long no data backet was received
  unsigned long lastPacket = DMXSerial.noDataSince();

  if (lastPacket < 5000) {
    // read recent DMX values and set values.
    
    strip1.Color(0, DMXSerial.read(1), DMXSerial.read(2), DMXSerial.read(3)); //Read DMX Address 1(red), 2(green), 3(blue) at pixel 1.
    strip1.show(); //Send to pixels.
    

  } else {
    // Show red on 3 first pixels when no data was received since 5 seconds or more.
    strip1.Color(0 + 1 + 2, 255, 0, 0);
    strip1.show();
  }
}

Tried to explain the best that i could in the comments, but the idea is to read DMX data on pin 0 and control the neopixel pixel by pixel with the values from dmx. Right now nothing happens. Not even the ELSE statement at the end.

{
    // Show red on 3 first pixels when no data was received since 5 seconds or more.
    strip1.Color(0 + 1 + 2, 255, 0, 0);
    strip1.show();
  }

That is equivalent to:

{
    // Show red on 3 first pixels when no data was received since 5 seconds or more.
    strip1.Color(3, 255, 0, 0);
    strip1.show();
  }

I don't think that will do what you want.

This is more likely to do what the comment says:

{
    // Show red on 3 first pixels when no data was received since 5 seconds or more.
   strip1.setPixelColor(0, red);
   strip1.setPixelColor(1, red);
   strip1.setPixelColor(2, red);
   strip1.show();
  }

johnwasser: {     // Show red on 3 first pixels when no data was received since 5 seconds or more.     strip1.Color(0 + 1 + 2, 255, 0, 0);     strip1.show();   }

That is equivalent to:

{
    // Show red on 3 first pixels when no data was received since 5 seconds or more.
    strip1.Color(3, 255, 0, 0);
    strip1.show();
  }

I don't think that will do what you want.

This is more likely to do what the comment says:

{
    // Show red on 3 first pixels when no data was received since 5 seconds or more.
   strip1.setPixelColor(0, red);
   strip1.setPixelColor(1, red);
   strip1.setPixelColor(2, red);
   strip1.show();
  }

Thanks, ill correct that right away! ;D Right now the ELSE statement works, but cant read from the DMXSerial..

Do i have to declare that its reading from pin 0 somehow? Any other ideas why it doesnt work?

Status at the moment, IF statement if running and working. DMX signal is working as it should.

Only problem is the DMXSerial to Neopixel part.

EDIT: Now its working, Simply wrong at the "Strip1.Color". Had to be "Strip1.setPixelColor".

Thanks for all the great help! :)