Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Re: Supernova_poi

by KasHoogeveen on Mon Jan 23, 2017 3:56 pm

laazarus wrote:just tested with the remote from my sony tv. just copied codes straight out of serial monitor and pasted into the code. turns out my tv remote has a better emmitter than the little adafruit one.

I think I got it.
I'm using a IR SENSOR - TSOP38238 which is working fine while using the simple irrecv commands. But with the supernova there's something going on with how sensitive the IR receiver is.
I've soldered another brand of ir receiver and now it's working like a charm! (woohoo) but I'm still wondering if a simple resistor could filter out the noise generated from the ir receiver.
Anyway, if that won't work I need to get a second receiver like the one I have now, which is working, and solder that on number two.

Posts: 11
Joined: Mon Jan 16, 2017 6:13 pm

Re: Supernova_poi

by laazarus on Mon Jan 23, 2017 4:30 pm

I'm using the TSOP38238. may be yours was a faulty and not performing correctly. important thing is your poi are working

Posts: 12
Joined: Tue Dec 20, 2016 7:50 pm

Re: Supernova_poi

by KasHoogeveen on Mon Jan 23, 2017 4:37 pm

laazarus wrote:I'm using the TSOP38238. may be yours was a faulty and not performing correctly. important thing is your poi are working

That would mean both are faulty? Could be.. Anyway. The poi is working. Thanks.

Posts: 11
Joined: Mon Jan 16, 2017 6:13 pm

Re: Supernova_poi

by DJ Namaste on Tue Nov 07, 2017 2:44 pm

Hi, I am having the same problem with my RGB led controller remote. I have entered the IR codes I get from the serial monitor so I know it is reading them correctly but they dont control the poi. Any idea why? If the codes are printing into the serial monitor it should control the poi. When I use a different IR example the board and IR receiver and remote are working together.
DJ Namaste
Posts: 36
Joined: Fri Feb 24, 2012 12:10 pm

Re: Supernova_poi

by DJ Namaste on Wed Nov 08, 2017 1:39 pm

Also, I am using an Adafruit Trinket MO for this. It does work with each case specifically called by remote but when it is coded as the standard sketch here https://github.com/adafruit/Kinetic_POV ... va_poi.ino, it does not work. Any ideas why?
DJ Namaste
Posts: 36
Joined: Fri Feb 24, 2012 12:10 pm

Re: Supernova_poi

by DJ Namaste on Thu Nov 09, 2017 1:09 am

I rearranged some things in the code and it is working now with my remote and it is using a similar structure. I dont understand why the code works for some using the sketch in the link I posted before. This one is working now though.
Code: Select all | TOGGLE FULL SIZE
  POV IR Supernova Poi sketch.  Uses the following Adafruit parts
  (X2 for two poi):

  - Teensy 3.2 (required - NOT compatible w/AVR-based boards)
  - 2200 mAh Lithium Ion Battery https://www.adafruit.com/product/1781
  - LiPoly Backpack https://www.adafruit.com/product/2124
  - 144 LED/m DotStar strip (#2328 or #2329)
    (ONE METER is enough for TWO poi)
  - Infrared Sensor: https://www.adafruit.com/product/157
  - Mini Remote Control: https://www.adafruit.com/product/389
    (only one remote is required for multiple poi)

  Needs Adafruit_DotStar library: github.com/adafruit/Adafruit_DotStar
  Also, uses version of IRremote library from the Teensyduino installer,
  the stock IRremote lib will NOT work here!

  This is based on the LED poi code (also included in the repository),
  but AVR-specific code has been stripped out for brevity, since these
  mega-poi pretty much require a Teensy 3.X.

  Adafruit invests time and resources providing this open source code,
  please support Adafruit and open-source hardware by purchasing
  products from Adafruit!

  Written by Phil Burgess / Paint Your Dragon for Adafruit Industries.
  MIT license, all text above must be included in any redistribution.
  See 'COPYING' file for additional notes.

#include <Arduino.h>
#include <Adafruit_DotStar.h>
//#include <avr/power.h>
//#include <avr/sleep.h>
#include <IRremote.h>
#include <SPI.h>

typedef uint16_t line_t;

// CONFIGURABLE STUFF ------------------------------------------------------

#include "nicksstaff.h" // Graphics data is contained in this header file.
// It's generated using the 'convert.py' Python script.  Various image
// formats are supported, trading off color fidelity for PROGMEM space.
// Handles 1-, 4- and 8-bit-per-pixel palette-based images, plus 24-bit
// truecolor.  1- and 4-bit palettes can be altered in RAM while running
// to provide additional colors, but be mindful of peak & average current
// draw if you do that!  Power limiting is normally done in convert.py
// (keeps this code relatively small & fast).

// Ideally you use hardware SPI as it's much faster, though limited to
// specific pins.  If you really need to bitbang DotStar data & clock on
// different pins, optionally define those here:
#define LED_DATA_PIN  0
#define LED_CLOCK_PIN 2

// Empty and full thresholds (millivolts) used for battery level display:
#define BATT_MIN_MV 3350 // Some headroom over battery cutoff near 2.9V
#define BATT_MAX_MV 4000 // And little below fresh-charged battery near 4.1V

boolean autoCycle = false; // Set to true to cycle images by default
uint32_t CYCLE_TIME = 12; // Time, in seconds, between auto-cycle images

int RECV_PIN = 4;
IRrecv irrecv(RECV_PIN);
decode_results results;

// Adafruit IR Remote Codes:
//   Button       Code         Button  Code
//   -----------  ------       ------  -----
//   VOL-:        0xFD00FF     0/10+:  0xFD30CF
//   Play/Pause:  0xFD807F     1:      0xFD08F7
//   VOL+:        0xFD40BF     2:      0xFD8877
//   SETUP:       0xFD20DF     3:      0xFD48B7
//   STOP/MODE:   0xFD609F     4:      0xFD28D7
//   UP:          0xFDA05F     5:      0xFDA857
//   DOWN:        0xFDB04F     6:      0xFD6897
//   LEFT:        0xFD10EF     7:      0xFD18E7
//   RIGHT:       0xFD50AF     8:      0xFD9867
//   ENTER/SAVE:  0xFD906F     9:      0xFD58A7
//   Back:        0xFD708F

#define BTN_BRIGHT_UP    0x8503705D   //|| 16187647
#define BTN_BRIGHT_DOWN  0xDEB0C861 //|| 16220287
#define BTN_RESTART      0xA2672345//|| 16236607 // bttn on
#define BTN_BATTERY      0xCE1972FD //|| 16203967 / unassigned
#define BTN_FASTER       0xFD805F
#define BTN_SLOWER       0xFDB04F
#define BTN_OFF          0xD4DD0381
#define BTN_PATTERN_NEXT 0xE85952E1
#define BTN_AUTOPLAY     0XFD906F
#define BTN_NONE       -1

//#define BTN_WHITE        2611188417 || 16244767
//#define BTN_RED          3898168033 || 16195807
//#define BTN_GREEN        2026743005 || 16228447
//#define BTN_BLUE         2724668229 || 16212127
//#define BTN_ORANGE        3556612737 || 16191727

// -------------------------------------------------------------------------

#if defined(LED_DATA_PIN) && defined(LED_CLOCK_PIN)
// Older DotStar LEDs use GBR order.  If colors are wrong, edit here.
Adafruit_DotStar strip = Adafruit_DotStar(NUM_LEDS,
Adafruit_DotStar strip = Adafruit_DotStar(NUM_LEDS, DOTSTAR_BGR);

void     imageInit(void),
uint16_t readVoltage(void);

void setup() {
  strip.begin(); // Allocate DotStar buffer, init SPI
  strip.clear(); // Make sure strip is clear
  strip.show();  // before measuring battery
  imageInit();   // Initialize pointers for default image

  irrecv.enableIRIn(); // Start the receiver

// GLOBAL STATE STUFF ------------------------------------------------------

uint32_t lastImageTime = 0L, // Time of last image change
         lastLineTime  = 0L;
uint8_t  imageNumber   = 0,  // Current image being displayed
         imageType,          // Image type: PALETTE[1,4,8] or TRUECOLOR
        *imagePalette,       // -> palette data in PROGMEM
        *imagePixels,        // -> pixel data in PROGMEM
         palette[16][3];     // RAM-based color table for 1- or 4-bit images
line_t   imageLines,         // Number of lines in active image
         imageLine;          // Current line number in image
volatile uint16_t irCode = BTN_NONE; // Last valid IR code received

const uint8_t PROGMEM brightness[] = { 15, 31, 63, 127, 255 };
uint8_t bLevel = sizeof(brightness) - 1;

// Microseconds per line for various speed settings
const uint16_t PROGMEM lineTable[] = { // 375 * 2^(n/3)
  1000000L /  375, // 375 lines/sec = slowest
  1000000L /  472,
  1000000L /  595,
  1000000L /  750, // 750 lines/sec = mid
  1000000L /  945,
  1000000L / 1191,
  1000000L / 1500  // 1500 lines/sec = fastest
uint8_t  lineIntervalIndex = 3;
uint16_t lineInterval      = 1000000L / 750;

void imageInit() { // Initialize global image state for current imageNumber
  imageType    = images[imageNumber].type;
  imageLines   = images[imageNumber].lines;
  imageLine    = 0;
  imagePalette = (uint8_t *)images[imageNumber].palette;
  imagePixels  = (uint8_t *)images[imageNumber].pixels;
  // 1- and 4-bit images have their color palette loaded into RAM both for
  // faster access and to allow dynamic color changing.  Not done w/8-bit
  // because that would require inordinate RAM (328P could handle it, but
  // I'd rather keep the RAM free for other features in the future).
  if(imageType == PALETTE1)      memcpy_P(palette, imagePalette,  2 * 3);
  else if(imageType == PALETTE4) memcpy_P(palette, imagePalette, 16 * 3);
  lastImageTime = millis(); // Save time of image init for next auto-cycle

void nextImage(void) {
  if(++imageNumber >= NUM_IMAGES) imageNumber = 0;

void prevImage(void) {
  imageNumber = imageNumber ? imageNumber - 1 : NUM_IMAGES - 1;

// MAIN LOOP ---------------------------------------------------------------

void loop() {
  uint32_t t = millis(); // Current time, milliseconds

  if(autoCycle) {
    if((t - lastImageTime) >= (CYCLE_TIME * 1000L)) nextImage();
    // CPU clocks vary slightly; multiple poi won't stay in perfect sync.
    // Keep this in mind when using auto-cycle mode, you may want to cull
    // the image selection to avoid unintentional regrettable combinations.

 while (irrecv.decode(&results == 0));
if  (irrecv.decode(&results)) {
    Serial.println(results.value, HEX);

        switch(results.value) {
         case BTN_BRIGHT_UP:
          if(bLevel < (sizeof(brightness) - 1))
         case BTN_BRIGHT_DOWN:
         case BTN_FASTER:
          if(lineIntervalIndex < (sizeof(lineTable) / sizeof(lineTable[0]) - 1))
           lineInterval = lineTable[++lineIntervalIndex];
         case BTN_SLOWER:
         if(CYCLE_TIME > 0) CYCLE_TIME--;
           lineInterval = lineTable[--lineIntervalIndex];
         case BTN_RESTART:
          imageNumber = 0;
         case BTN_OFF:
         case BTN_PATTERN_PREV:
         case BTN_PATTERN_NEXT:
         case BTN_AUTOPLAY:
          autoCycle = !autoCycle;
      results.value = BTN_NONE;

  strip.show(); // Refresh LEDs
  lastLineTime = t;

void IRinterrupt() {
  if (irrecv.decode(&results)) {
    Serial.println(results.value, DEC);
    irrecv.resume(); // Receive the next value

void imageswitchs() {
 switch(imageType) {

    case PALETTE1: { // 1-bit (2 color) palette-based image
      uint8_t  pixelNum = 0, byteNum, bitNum, pixels, idx,
              *ptr = (uint8_t *)&imagePixels[imageLine * NUM_LEDS / 8];
      for(byteNum = NUM_LEDS/8; byteNum--; ) { // Always padded to next byte
        pixels = *ptr++;                       // 8 pixels of data (pixel 0 = LSB)
        for(bitNum = 8; bitNum--; pixels >>= 1) {
          idx = pixels & 1; // Color table index for pixel (0 or 1)
            palette[idx][0], palette[idx][1], palette[idx][2]);

    case PALETTE4: { // 4-bit (16 color) palette-based image
      uint8_t  pixelNum, p1, p2,
              *ptr = (uint8_t *)&imagePixels[imageLine * NUM_LEDS / 2];
      for(pixelNum = 0; pixelNum < NUM_LEDS; ) {
        p2  = *ptr++;  // Data for two pixels...
        p1  = p2 >> 4; // Shift down 4 bits for first pixel
        p2 &= 0x0F;    // Mask out low 4 bits for second pixel
          palette[p1][0], palette[p1][1], palette[p1][2]);
          palette[p2][0], palette[p2][1], palette[p2][2]);

    case PALETTE8: { // 8-bit (256 color) PROGMEM-palette-based image
      uint16_t  o;
      uint8_t   pixelNum,
               *ptr = (uint8_t *)&imagePixels[imageLine * NUM_LEDS];
      for(pixelNum = 0; pixelNum < NUM_LEDS; pixelNum++) {
        o = *ptr++ * 3; // Offset into imagePalette
          imagePalette[o + 1],
          imagePalette[o + 2]);

    case TRUECOLOR: { // 24-bit ('truecolor') image (no palette)
      uint8_t  pixelNum, r, g, b,
              *ptr = (uint8_t *)&imagePixels[imageLine * NUM_LEDS * 3];
      for(pixelNum = 0; pixelNum < NUM_LEDS; pixelNum++) {
        r = *ptr++;
        g = *ptr++;
        b = *ptr++;
        strip.setPixelColor(pixelNum, r, g, b);

DJ Namaste
Posts: 36
Joined: Fri Feb 24, 2012 12:10 pm

Re: Supernova_poi

by DJ Namaste on Sat Nov 11, 2017 2:44 pm

After checking the outcome of the changes made, the patterns are slowed down. If I run the original sketch without IR input, the patterns run faster. When I alter it so it does receive IR input, the patterns are slower. Anyone? Anyone? :/
DJ Namaste
Posts: 36
Joined: Fri Feb 24, 2012 12:10 pm

Re: Supernova_poi

by laazarus on Mon Nov 13, 2017 9:23 am

I'm not much of a coder (not at all really) but I can try and throw a few ideas into the mix. when you say slower do you mean that it is slower producing each column of an image so every thing looks stretched out, or slower changing between images so the timing goes out of sync with music?
The trinket m0 doesn't run as fast or have some of the more advanced features as the teensy the project was originally designed for so it could just be a lack of horse power to handle ir and imaging.
It would be nice to get this working well on cheaper hardware, I've lost count of the number of people who've asked me to build them a set but then decided not to go ahead when they hear the cost.

Just been looking at the pin outs for the M0 and your code. could be that in practice the code to physical pin mapping is a bit different but by the looks of it the hardware SPI support on the M0 is on pins 3 and 4 where as you're using 0 and 2. if this is the case could shifting on to the hardware spi take a bit of load off the processor. failing that there is also the on board dotstar led. what happens if you take clock and data direct from its pins? (7 and 8)

Posts: 12
Joined: Tue Dec 20, 2016 7:50 pm

Re: Supernova_poi

by DJ Namaste on Mon Nov 13, 2017 12:01 pm

You were right about the hardware SPI pins. I thought I read the hardware spi pins were 0 and 2. It now runs fast at the right speed using pins 3 and 4 but the flash after each display is still there. I think the first 32 pixels are dumping remaining data to the rest of the leds and it causes random flashing. I dont know how to get rid of it. It is so fast that it is kind of unnoticeable but it is annoying. Also, about the IR remote: Does the original example sketch work on github? I can not get my remote to work with the code unless I get rid of this part:

Code: Select all | TOGGLE FULL SIZE
if(results.value != BTN_NONE) {
      if(!strip.getBrightness()) { // If strip is off...
        // Set brightness to last level
        // and ignore button press (don't fall through)
        // effectively, first press is 'wake'
      } else {
DJ Namaste
Posts: 36
Joined: Fri Feb 24, 2012 12:10 pm

Re: Supernova_poi

by DJ Namaste on Mon Nov 13, 2017 12:09 pm


This video shows the single dot running down the strip and the flash that happens in between each scan of the image.
DJ Namaste
Posts: 36
Joined: Fri Feb 24, 2012 12:10 pm

Re: Supernova_poi

by DJ Namaste on Mon Nov 13, 2017 12:39 pm

When I reconnected the pins I changed the IR pin and now the sketch works with the IR remote. Odd that it worked before if I modified the sketch.
DJ Namaste
Posts: 36
Joined: Fri Feb 24, 2012 12:10 pm

Please be positive and constructive with your questions and comments.