SEWRGB v0

This product has been replaced by the SEWRGB v2 pixel.

awesomeness.openphoto
The SEWRGB pixel is a sewable RGB pixel for wearable projects.

At the heart of the SEWRGB v0.1 pixel is a WS2812 LED. The WS2812 is an interesting device which has a SMD5050 RGB LED combined with a built in WS2811 controller chip. This chip controls the current to each of the internal LEDs and using PWM can produce 24-bit colour.

SEWRGB pixels can be daisy-chained into strings that can all be individuality controlled by a single pin on the micro controller. Though because of the possible hight current (~60mA) used per pixel and the high resistance in conductive thread, the number of pixels in a string and the spacing between them should be limited.

The flicker visible in the video is likely caused in part by this problem. A possible solution is to use copper wire or metal connection materials instead of conduction thread.

The board is 14mm in diameter with a thickness of 1.6mm and supplied pre-assembled.

My SEWRGB boards are availalbe for purchase from my Tindie store.

sewrgb_example_bbAn example layout with an Arduino Uno is shown to the right. The connections can be made with wire or crocodile clips. All the connection on the SEWRGB boards should be connected together and then to the GND pin on the Arduino, and a similar arrangement for the + connections to the 5V pin. PIN 12 on the Arduino should then be connected to the I connection on the first SEWRGB board, then repeatly connect O connection to the I connection on the next SEWRGB.

Then the following code can be loaded on to the Arduino:

#define SEWRGB_PIN 12

#define LED_COUNT 5
uint8_t leds[LED_COUNT][3];

void setup() {
  pinMode(SEWRGB_PIN, OUTPUT);
  digitalWrite(SEWRGB_PIN, LOW);
}

#define DOBIT(_bit) do { \
  if ((_bit)) { \
    *out |= bit; \
    *out |= bit; \
    *out |= bit; \
    *out &= ~bit; \
    *out &= ~bit; \
  } else { \
    *out |= bit; \
    *out &= ~bit; \
    *out &= ~bit; \
    *out &= ~bit; \
    *out &= ~bit; \
  } \
} while (0);
#define DOBYTE(_byte) do { \
  const uint8_t __byte = (_byte); \
  DOBIT((__byte) & 0b10000000); \
  DOBIT((__byte) & 0b01000000); \
  DOBIT((__byte) & 0b00100000); \
  DOBIT((__byte) & 0b00010000); \
  DOBIT((__byte) & 0b00001000); \
  DOBIT((__byte) & 0b00000100); \
  DOBIT((__byte) & 0b00000010); \
  DOBIT((__byte) & 0b00000001); \
} while (0);
#define DORGB(_r,_g,_b) do { \
  DOBYTE(_g); \
  DOBYTE(_r); \
  DOBYTE(_b); \
} while (0);

void show(const uint8_t pin) {
  const uint8_t bit = digitalPinToBitMask(pin);
  const uint8_t port = digitalPinToPort(pin);
  volatile uint8_t * out = portOutputRegister(port);
  *out &= ~bit;

  noInterrupts();
  for (int i = 0; i < LED_COUNT; i++) {
    DORGB(leds[i][0], leds[i][1], leds[i][2]);
  }
  *out &= ~bit;
  interrupts();
}

void setpixel(const int index, const uint8_t r, const uint8_t g, const uint8_t b) {
  leds[index][0] = r;
  leds[index][1] = g;
  leds[index][2] = b;
}
void fill(const uint8_t r, const uint8_t g, const uint8_t b) {
  for (int i = 0; i < LED_COUNT; i++) {
    setpixel(i, r, g, b);
  }
}

void loop() {
  const uint8_t ONE = 0b00111111;
  const uint8_t ZERO = 0b00000000;
  const int DELAY = 2000;

  fill(ONE, ZERO, ZERO);
  show(SEWRGB_PIN);
  delay(DELAY);

  fill(ZERO, ONE, ZERO);
  show(SEWRGB_PIN);
  delay(DELAY);

  fill(ZERO, ZERO, ONE);
  show(SEWRGB_PIN);
  delay(DELAY);

  fill(ONE, ONE, ONE);
  show(SEWRGB_PIN);
  delay(DELAY);

  fill(ZERO, ZERO, ZERO);
  show(SEWRGB_PIN);
  delay(DELAY);
}

WS2812 Datasheet