Spiral LED strips messages

Hi,

Was wondering if someone could see what was wrong if my code for the following purpose. I’m trying to display simple messages which spirals. I coiled 5m of LED strips around a tin-can, and would want to display simple messages like “hi” to it.

However, right now, the messages appear to be slanted. Not sure what’s wrong with the mapping function.
Do note that I’m not cutting and soldering the strips, but instead coiling it around. Can someone kind enough please take a look and advise. Thank you.

I’m using a 5m (96 pixels per metre strips) =)

Attached is the image of the problem.

#include <Adafruit_GFX.h>
#include <Adafruit_NeoMatrix.h>
#include <Adafruit_NeoPixel.h>
#ifndef PSTR
#define PSTR // Make Arduino Due happy
#endif

#define PIN 6

// MATRIX DECLARATION:
// Parameter 1 = width of NeoPixel matrix
// Parameter 2 = height of matrix
// Parameter 3 = pin number (most are valid)
// Parameter 4 = matrix layout flags, add together as needed:
//   NEO_MATRIX_TOP, NEO_MATRIX_BOTTOM, NEO_MATRIX_LEFT, NEO_MATRIX_RIGHT:
//     Position of the FIRST LED in the matrix; pick two, e.g.
//     NEO_MATRIX_TOP + NEO_MATRIX_LEFT for the top-left corner.
//   NEO_MATRIX_ROWS, NEO_MATRIX_COLUMNS: LEDs are arranged in horizontal
//     rows or in vertical columns, respectively; pick one or the other.
//   NEO_MATRIX_PROGRESSIVE, NEO_MATRIX_ZIGZAG: all rows/columns proceed
//     in the same order, or alternate lines reverse direction; pick one.
//   See example below for these values in action.
// Parameter 5 = pixel type flags, add together as needed:
//   NEO_KHZ800  800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
//   NEO_KHZ400  400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
//   NEO_GRB     Pixels are wired for GRB bitstream (most NeoPixel products)
//   NEO_RGB     Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)


// Example for NeoPixel Shield.  In this application we'd like to use it
// as a 5x8 tall matrix, with the USB port positioned at the top of the
// Arduino.  When held that way, the first pixel is at the top right, and
// lines are arranged in columns, progressive order.  The shield uses
// 800 KHz (v2) pixels that expect GRB color data.
Adafruit_NeoMatrix matrix = Adafruit_NeoMatrix(60, 8, PIN,
 NEO_MATRIX_TOP     + NEO_MATRIX_RIGHT +
 NEO_MATRIX_ROWS + NEO_MATRIX_PROGRESSIVE,
 NEO_GRB            + NEO_KHZ800);

const uint16_t colors[] = {
 matrix.Color(255, 0, 0), matrix.Color(0, 255, 0), matrix.Color(0, 0, 255) };

void setup() {
 matrix.begin();
 matrix.setTextWrap(false);
 matrix.setBrightness(40);
 matrix.setTextColor(colors[0]);
}

int x    = matrix.width();
int pass = 0;

void loop() {
 matrix.fillScreen(0);
 matrix.setCursor(x, 0);
 matrix.print(F("H e l l o "));
 if(--x < -36) {
   x = matrix.width();
   if(++pass >= 3) pass = 0;
   matrix.setTextColor(colors[pass]);
 }
 matrix.show();
 delay(100);
}

From the picture the LEDs are not aligned vertically so it is always going to be slanting.

I would play about with the Parameter 1 = width of NeoPixel matrix, How many LEDs are their in one turn of the display?

Hi, thanks for the reply.
It is about 60 pixels per round, 8 rows in total. (I'm using 5m, 96 pixels per m strips. Hence in total, i have 480 pixels.)

I came across this tutorial which does what I intend to do but I am unable to remove all the unwanted Bluetooth part of the code due to my in proficiency in Arduino. Hope someone can spare some time to help me out with this.

Looks more like about 59.17 pixels per row. By saying 60 you are getting each row offset by almost a full pixel. Add a little padding to make it exactly 59 pixels per turn or add more padding to make it exactly 60. That should get rid of the slanting.

johnwasser:
Looks more like about 59.17 pixels per row. By saying 60 you are getting each row offset by almost a full pixel. Add a little padding to make it exactly 59 pixels per turn or add more padding to make it exactly 60. That should get rid of the slanting.

hi, thank you for the suggestion. You have raised an important concern. However, could I clairfy what do you mean by adding paddings? Thank you sir

could I clairfy what do you mean by adding paddings?

Put something underneath the strip so the circumference is greater.

From the photograph it looks like you are using a base that is not cylindrical so the number of LEDs per turn is not going to be constant. You could compensate for this in your software but not using that library.

You want to make the diameter of your form slightly larger so after 59 LED's the 60th lines up directly under the 1st. Or make the form even larger so the 61st lines up under the 1st to get 60 per row.

Noted with thanks to all! Will try this changes and feedback! =)

Hi,

I am currently working on a spiralled display and have a simple program that allows for texts to be displayed off a spiral LED matrix (5m long).

Can someone please help me as I try to change this code to use non-blocking coding instead so that I can run another process in the main loop while this led scrolling text code is running in the background?

Here’s my original code.

Thank you

#include <Adafruit_GFX.h>
#include <Adafruit_NeoMatrix.h>
#include <Adafruit_NeoPixel.h>
#ifndef PSTR
 #define PSTR // Make Arduino Due happy
#endif

#define PIN 6


Adafruit_NeoMatrix matrix = Adafruit_NeoMatrix(34, 8, PIN,
  NEO_MATRIX_BOTTOM     + NEO_MATRIX_RIGHT +
  NEO_MATRIX_ROWS + NEO_MATRIX_PROGRESSIVE,
  NEO_GRB            + NEO_KHZ800);

const uint16_t colors[] = {
  matrix.Color(255, 0, 0), matrix.Color(0, 255, 0), matrix.Color(0, 0, 255) };

void setup() {
  matrix.begin();
  matrix.setTextWrap(false);
  matrix.setBrightness(40);
  matrix.setTextColor(colors[0]);
}

int x    = matrix.width();
int pass = 0;

void loop() {
  matrix.fillScreen(0);
  matrix.setCursor(x, 0);
  matrix.print(F("Hello"));
  if(--x < -36) {
    x = matrix.width();
    if(++pass >= 3) pass = 0;
    matrix.setTextColor(colors[pass]);
  }
  matrix.show();
  delay(100);
}

You should continue over at your original post.
No need to start all over.

Threads merged.

See the BlinkWithoutDelay example. Instead of:

void loop() {
    /////// DO STUFF //////
  delay(100);
}

use

unsigned long previousMillis = 0;        // will store last time LED was updated
const long interval = 100;
void loop() {
  unsigned long currentMillis = millis();
  if (currentMillis - previousMillis >= interval) {
    previousMillis += interval;
    /////// DO STUFF //////
  }
  //// DO OTHER STUFF ////
}

Sorry. I realised I should have been more careful in not creating mutiple threads revolving on similar issues but rather continuing it on the same thread. My apologies on that. As advised by fellow forumer ieee488, I will post my query here instead as a continuation.


I'm thinking of converting my spiral LEDs to a non-uniform circumferential arrangement. Meaning to say, as the height progresses, the circumference/diameter of the cylinder reduces (gets smaller and smaller).

Would I still be able to port the scrolling matrix code over? Now that, since the width (num of pixels per layer) is different.

Would I still be able to port the scrolling matrix code over? Now that, since the width (num of pixels per layer) is different.

Well it would need modifying to cope with the width changing with the Y coordinate, but it is doable.

Thanks!

I'm currently trying to figure out how the neopixel library remapping function works.

For example, let's say I have 6 rows of spirally coiled progressive LEDs in this particular order (assuming X is the number of LEDS present per layer):

(formatting looks off, but the idea is that as each row progresses upwards, the total number of LEDs decreases by a fixed number. (Last layer 30 led, 2nd last layer 28, 3rd last layer 26 etc..)

XXXXX
XXXXXXX
XXXXXXXXX 
XXXXXXXXXXX
XXXXXXXXXXXXX
XXXXXXXXXXXXXXX

Not really sure how I should go about with the remapping.
Tried playing around with offsets but it just doesn't look right logically

#define NEO_OFFSET  (((NEO_WIDTH * NEO_HEIGHT) - 300) / 2)

uint16_t remapXY(uint16_t x, uint16_t y) {
  return y * NEO_WIDTH + x - NEO_OFFSET;
}

Thank you all for the continuous support thus far!