[RELEASE] Official XBMC boblight Addon
Hey guys, hoping for a little assistance, I put together my first Arduino Boblight tonight, and it was all going marvellously. I used the following code

Code:
/* t4a_boblight
* (C) 2014 Hans Luijten, www.tweaking4all.com
*
* t4a_boblight is free software and can be distributed and/or modified
* freely as long as the copyright notice remains in place.
* Nobody is allowed to charge you for this code.
* Use of this code is entirely at your own risk.
*/

#include "Adafruit_NeoPixel.h"

// DEFINITIONS

#define STARTCOLOR 0xFFFFFF  // LED colors at start
#define BLACK      0x000000  // LED color BLACK

#define DATAPIN    6        // Datapin
#define LEDCOUNT   150       // Number of LEDs used for boblight
#define SHOWDELAY  200       // Delay in micro seconds before showing
#define BAUDRATE   460800    // Serial port speed, 460800 tested with Arduino Uno R3
#define BRIGHTNESS 90        // Max. brightness in %

const char prefix[] = {
  0x41, 0x64, 0x61, 0x00, 0x95, 0xC0};  // Start prefix
char buffer[sizeof(prefix)]; // Temp buffer for receiving prefix data

// Init LED strand, WS2811/WS2912 specific

// These might work for other configurations:
//   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)

Adafruit_NeoPixel strip = Adafruit_NeoPixel(LEDCOUNT, DATAPIN, NEO_GRB + NEO_KHZ800);

int state;                   // Define current state
#define STATE_WAITING   1    // - Waiting for prefix
#define STATE_DO_PREFIX 2    // - Processing prefix
#define STATE_DO_DATA   3    // - Handling incoming LED colors

int readSerial;           // Read Serial data (1)
int currentLED;           // Needed for assigning the color to the right LED

void setup()
{
  strip.begin();            // Init LED strand, set all black, then all to startcolor

  strip.setBrightness( (255 / 100) * BRIGHTNESS );

  setAllLEDs(BLACK, 0);
  setAllLEDs(STARTCOLOR, 5);

  Serial.begin(BAUDRATE);   // Init serial speed

  state = STATE_WAITING;    // Initial state: Waiting for prefix
}


void loop()
{
  switch(state)
  {
  case STATE_WAITING:                  // *** Waiting for prefix ***
    if( Serial.available()>0 )
    {
      readSerial = Serial.read();      // Read one character

      if ( readSerial == prefix[0] )   // if this character is 1st prefix char
      {
        state = STATE_DO_PREFIX;
      }   // then set state to handle prefix
    }
    break;


  case STATE_DO_PREFIX:                // *** Processing Prefix ***
    if( Serial.available() > sizeof(prefix) - 2 )
    {
      Serial.readBytes(buffer, sizeof(prefix) - 1);

      for( int Counter = 0; Counter < sizeof(prefix) - 1; Counter++)
      {
        if( buffer[Counter] == prefix[Counter+1] )
        {
          state = STATE_DO_DATA;     // Received character is in prefix, continue
          currentLED = 0;            // Set current LED to the first one
        }
        else
        {
          state = STATE_WAITING;     // Crap, one of the received chars is NOT in the prefix
          break;                     // Exit, to go back to waiting for the prefix
        } // end if buffer
      } // end for Counter
    } // end if Serial
    break;


  case STATE_DO_DATA:                  // *** Process incoming color data ***
    if( Serial.available() > 2 )       // if we receive more than 2 chars
    {
      Serial.readBytes( buffer, 3 );   // Abuse buffer to temp store 3 charaters
      strip.setPixelColor( currentLED++, buffer[0], buffer[1], buffer[2]);  // and assing to LEDs
    }

    if( currentLED > LEDCOUNT )        // Reached the last LED? Display it!
    {
      strip.show();                  // Make colors visible
      delayMicroseconds(SHOWDELAY);  // Wait a few micro seconds

      state = STATE_WAITING;         // Reset to waiting ...
      currentLED = 0;                // and go to LED one

      break;                         // and exit ... and do it all over again
    }
    break;
  } // switch(state)

} // loop


// Sets the color of all LEDs in the strand to 'color'
// If 'wait'>0 then it will show a swipe from start to end
void setAllLEDs(uint32_t color, int wait)
{
  for ( int Counter=0; Counter < LEDCOUNT; Counter++ )      // For each LED
  {
    strip.setPixelColor( Counter, color );      // .. set the color

      if( wait > 0 )                        // if a wait time was set then
    {
      strip.show();                     // Show the LED color
      delay(wait);                      // and wait before we do the next LED
    } // if wait

  } // for Counter

  strip.show();                         // Show all LEDs
} // setAllLEDs

Prefix was calculated with the processing script mentioned earlier in this post to be 41 64 61 00 95 C0 with 150 LEDs.

However, using the boblight config generator and changing the prefix accordingly. The first 50 LED's appear to work perfectly, no matter how many I change it to, everything after that flashes wildly in different colours! The NeoPixel test script for the arduino however works flawlessly.

Any suggestions and help greatly appreciated.
Reply


Messages In This Thread
[No subject] - by Lunatixz - 2011-12-07, 08:22
[No subject] - by Memphiz - 2011-12-07, 09:15
[No subject] - by Memphiz - 2011-12-07, 10:01
[No subject] - by Lunatixz - 2011-12-07, 11:05
[No subject] - by snipah - 2011-12-07, 12:11
[No subject] - by Memphiz - 2011-12-07, 12:32
[No subject] - by Clumsy - 2011-12-07, 13:29
[No subject] - by snipah - 2011-12-07, 13:52
[No subject] - by Memphiz - 2011-12-07, 18:41
[No subject] - by Memphiz - 2011-12-07, 18:47
[No subject] - by snipah - 2011-12-07, 21:04
[No subject] - by Memphiz - 2011-12-07, 21:09
[No subject] - by Memphiz - 2011-12-07, 21:10
[No subject] - by snipah - 2011-12-07, 21:36
[No subject] - by Memphiz - 2011-12-07, 21:39
[No subject] - by Memphiz - 2011-12-07, 22:12
[No subject] - by snipah - 2011-12-07, 23:16
[No subject] - by Memphiz - 2011-12-08, 00:36
[No subject] - by snipah - 2011-12-08, 08:39
[No subject] - by Elbert - 2011-12-09, 17:11
[No subject] - by lordindy - 2011-12-09, 17:16
[No subject] - by Elbert - 2011-12-10, 14:21
[No subject] - by Memphiz - 2011-12-10, 15:09
[No subject] - by Elbert - 2011-12-10, 16:20
[No subject] - by Memphiz - 2011-12-10, 16:43
[No subject] - by Elbert - 2011-12-10, 17:16
[No subject] - by Memphiz - 2011-12-10, 17:46
[No subject] - by bobo1on1 - 2011-12-10, 18:14
[No subject] - by Elbert - 2011-12-10, 19:05
[No subject] - by Lunatixz - 2011-12-13, 05:45
[No subject] - by Memphiz - 2011-12-13, 10:01
[No subject] - by Lunatixz - 2011-12-13, 21:25
[No subject] - by Memphiz - 2011-12-14, 00:11
[No subject] - by Dannydeman - 2011-12-18, 23:42
[No subject] - by Memphiz - 2011-12-18, 23:54
[No subject] - by bleze - 2011-12-19, 00:01
[No subject] - by bleze - 2011-12-19, 00:23
[No subject] - by Memphiz - 2011-12-19, 10:56
[No subject] - by Kode - 2011-12-19, 13:49
[No subject] - by bleze - 2011-12-19, 22:04
[No subject] - by Memphiz - 2011-12-19, 22:17
[No subject] - by bleze - 2011-12-19, 22:31
[No subject] - by Memphiz - 2011-12-19, 23:37
[No subject] - by bleze - 2011-12-20, 19:15
[No subject] - by bleze - 2011-12-20, 21:18
[No subject] - by bobo1on1 - 2011-12-20, 23:41
[No subject] - by Memphiz - 2011-12-21, 14:07
[No subject] - by bleze - 2011-12-21, 18:01
[No subject] - by Memphiz - 2011-12-21, 19:58
[No subject] - by Wikking - 2011-12-22, 12:43
[No subject] - by Memphiz - 2011-12-22, 16:34
[No subject] - by Wikking - 2011-12-22, 17:28
[No subject] - by ECEC - 2011-12-22, 18:07
[No subject] - by bobo1on1 - 2011-12-22, 18:55
[No subject] - by ECEC - 2011-12-22, 20:44
[No subject] - by bobo1on1 - 2011-12-22, 21:20
[No subject] - by Eoghlear - 2011-12-23, 00:57
[No subject] - by bobo1on1 - 2011-12-23, 03:10
[No subject] - by metheos - 2011-12-24, 22:45
[No subject] - by bleze - 2011-12-27, 01:23
[No subject] - by Eoghlear - 2011-12-27, 18:03
[No subject] - by bobo1on1 - 2011-12-27, 18:58
[No subject] - by Adam B. - 2011-12-28, 16:55
[No subject] - by bobo1on1 - 2011-12-28, 17:18
[No subject] - by Adam B. - 2011-12-28, 17:31
[No subject] - by Memphiz - 2011-12-29, 01:28
[No subject] - by Adam B. - 2011-12-29, 03:59
[No subject] - by Wikking - 2011-12-29, 11:22
[No subject] - by Adam B. - 2011-12-29, 12:11
[No subject] - by Wikking - 2011-12-29, 14:19
[No subject] - by bobo1on1 - 2011-12-29, 17:47
[No subject] - by bleze - 2011-12-29, 18:18
[No subject] - by Adam B. - 2011-12-30, 04:14
[No subject] - by LastMile - 2011-12-30, 05:43
[No subject] - by Memphiz - 2011-12-30, 13:04
[No subject] - by Adam B. - 2011-12-30, 13:47
[No subject] - by sraue - 2011-12-30, 16:22
were to buy - by pang - 2012-01-01, 09:17
[No subject] - by Elbert - 2012-01-01, 12:38
[No subject] - by LastMile - 2012-01-01, 23:34
[No subject] - by pigr8 - 2012-01-05, 04:10
[No subject] - by xalaros - 2012-01-06, 12:24
[No subject] - by schumi2004 - 2012-01-06, 12:44
[No subject] - by Memphiz - 2012-01-06, 15:00
[No subject] - by Ghostface - 2012-01-09, 11:42
[No subject] - by Memphiz - 2012-01-09, 13:10
[No subject] - by trouty00 - 2012-01-09, 15:29
[No subject] - by trouty00 - 2012-01-09, 18:31
[No subject] - by Memphiz - 2012-01-09, 21:31
[No subject] - by trouty00 - 2012-01-09, 23:36
[No subject] - by bobo1on1 - 2012-01-10, 00:18
[No subject] - by trouty00 - 2012-01-10, 17:27
[No subject] - by bobo1on1 - 2012-01-10, 20:12
[No subject] - by regnets - 2012-01-10, 22:49
[No subject] - by kimp93 - 2012-01-11, 01:54
[No subject] - by Memphiz - 2012-01-11, 14:52
[No subject] - by bobo1on1 - 2012-01-11, 18:40
[No subject] - by kimp93 - 2012-01-11, 21:30
[No subject] - by regnets - 2012-01-12, 09:38
[No subject] - by Memphiz - 2012-01-12, 11:13
[No subject] - by regnets - 2012-01-12, 13:59
[No subject] - by regnets - 2012-01-15, 23:05
[No subject] - by m_K_o - 2012-01-21, 19:39
[No subject] - by Lunatixz - 2012-01-22, 07:17
[No subject] - by Memphiz - 2012-01-22, 12:49
[No subject] - by kimp93 - 2012-01-24, 17:51
[No subject] - by Memphiz - 2012-01-24, 20:33
[No subject] - by MrHenky - 2012-01-24, 21:08
[No subject] - by bobo1on1 - 2012-01-24, 21:14
[No subject] - by kimp93 - 2012-01-24, 21:29
[No subject] - by MrHenky - 2012-01-24, 22:32
[No subject] - by devnull - 2012-01-25, 22:01
Possible Feature Addition? - by DarioS - 2012-01-25, 22:29
[No subject] - by Memphiz - 2012-01-26, 00:11
[No subject] - by MrHenky - 2012-01-26, 15:17
[No subject] - by ski107 - 2012-01-28, 09:10
[No subject] - by ski107 - 2012-01-28, 09:13
[No subject] - by PolliSoft - 2012-01-28, 14:50
[No subject] - by MrHenky - 2012-01-28, 23:42
[No subject] - by PolliSoft - 2012-01-29, 00:23
[No subject] - by ski107 - 2012-01-29, 02:04
[No subject] - by MrHenky - 2012-01-29, 15:45
[No subject] - by silvine - 2012-01-29, 18:50
[No subject] - by ski107 - 2012-01-29, 18:52
[No subject] - by MrHenky - 2012-01-29, 19:19
[No subject] - by MrHenky - 2012-01-30, 00:41
[No subject] - by Memphiz - 2012-01-30, 12:55
[No subject] - by devnull - 2012-01-30, 13:05
[No subject] - by Scidd0w - 2012-01-30, 18:09
[No subject] - by Lunatixz - 2012-02-01, 01:21
[No subject] - by PolliSoft - 2012-02-02, 12:52
[No subject] - by MrHenky - 2012-02-03, 20:01
[No subject] - by Adam B. - 2012-02-03, 20:57
[No subject] - by PolliSoft - 2012-02-06, 00:20
[No subject] - by Memphiz - 2012-02-06, 00:26
[No subject] - by bobo1on1 - 2012-02-06, 00:39
[No subject] - by PolliSoft - 2012-02-06, 01:14
[No subject] - by bobo1on1 - 2012-02-06, 01:29
[No subject] - by PolliSoft - 2012-02-06, 08:41
[No subject] - by Lunatixz - 2012-02-07, 01:52
[No subject] - by Memphiz - 2012-02-07, 11:33
[No subject] - by PolliSoft - 2012-02-07, 11:57
[No subject] - by bobo1on1 - 2012-02-07, 16:37
[No subject] - by MrHenky - 2012-02-08, 11:47
[No subject] - by smajor - 2012-02-12, 15:50
[No subject] - by Memphiz - 2012-02-12, 23:26
[No subject] - by Lunatixz - 2012-02-13, 00:57
[No subject] - by smajor - 2012-02-13, 10:49
[No subject] - by smajor - 2012-02-13, 11:26
[No subject] - by Lunatixz - 2012-02-13, 19:22
[No subject] - by smajor - 2012-02-13, 19:33
[No subject] - by George - 2012-02-13, 20:06
[No subject] - by smajor - 2012-02-13, 20:58
SEDU-Box and Boblight - by XBMCManni - 2012-02-15, 16:55
hardware setup - by Monkeysweat - 2012-02-15, 20:31
[No subject] - by George - 2012-02-16, 11:22
[No subject] - by smajor - 2012-02-16, 12:32
[No subject] - by Memphiz - 2012-02-16, 12:43
[No subject] - by phil65 - 2012-02-16, 15:04
[No subject] - by draven187 - 2012-02-16, 17:09
[No subject] - by triberraar - 2012-02-18, 14:12
[No subject] - by Adam B. - 2012-02-18, 16:28
[No subject] - by triberraar - 2012-02-18, 18:22
[No subject] - by smajor - 2012-02-18, 20:24
[No subject] - by Memphiz - 2012-02-19, 02:19
[No subject] - by smajor - 2012-02-19, 11:10
[No subject] - by triberraar - 2012-02-19, 14:33
[No subject] - by schumi2004 - 2012-02-21, 13:38
[No subject] - by hotlobster - 2012-02-21, 14:44
[No subject] - by Memphiz - 2012-02-21, 16:54
[No subject] - by Memphiz - 2012-02-21, 16:55
[No subject] - by hotlobster - 2012-02-21, 18:28
[No subject] - by bobo1on1 - 2012-02-21, 18:41
[No subject] - by Memphiz - 2012-02-22, 10:51
[No subject] - by Memphiz - 2012-02-22, 10:53
[No subject] - by hotlobster - 2012-02-22, 11:06
[No subject] - by Memphiz - 2012-02-22, 17:00
[No subject] - by phil65 - 2012-02-27, 05:22
[No subject] - by Memphiz - 2012-02-27, 12:48
[No subject] - by schumi2004 - 2012-02-27, 15:28
[No subject] - by phil65 - 2012-02-27, 18:37
[No subject] - by schumi2004 - 2012-02-29, 23:30
[No subject] - by Memphiz - 2012-03-01, 11:02
[No subject] - by schumi2004 - 2012-03-01, 18:18
[No subject] - by Memphiz - 2012-03-01, 23:27
[No subject] - by schumi2004 - 2012-03-01, 23:53
[No subject] - by Memphiz - 2012-03-02, 10:32
[No subject] - by bobo1on1 - 2012-03-02, 17:03
[No subject] - by schumi2004 - 2012-03-02, 20:11
[No subject] - by phil65 - 2012-03-03, 04:56
[No subject] - by schumi2004 - 2012-03-03, 13:29
[No subject] - by bobo1on1 - 2012-03-03, 16:56
[No subject] - by phil65 - 2012-03-03, 18:27
[No subject] - by schumi2004 - 2012-03-03, 18:41
[No subject] - by beta-j - 2012-03-03, 23:57
[No subject] - by bobo1on1 - 2012-03-04, 00:49
[No subject] - by Memphiz - 2012-03-04, 03:11
[No subject] - by phil65 - 2012-03-04, 11:37
[No subject] - by beta-j - 2012-03-04, 13:58
RE: - by phil65 - 2012-03-12, 07:53
RE: - by beta-j - 2012-03-12, 10:56
RE: - by phil65 - 2012-03-13, 00:51
RE: - by beta-j - 2012-03-14, 13:14
[No subject] - by Memphiz - 2012-03-04, 14:50
[No subject] - by bobo1on1 - 2012-03-04, 17:31
[No subject] - by phil65 - 2012-03-04, 19:06
[No subject] - by Memphiz - 2012-03-05, 00:36
[No subject] - by beta-j - 2012-03-05, 11:13
[No subject] - by schumi2004 - 2012-03-05, 15:39
[No subject] - by bobo1on1 - 2012-03-05, 16:19
[No subject] - by beta-j - 2012-03-05, 16:21
[No subject] - by bobo1on1 - 2012-03-06, 04:16
[No subject] - by beta-j - 2012-03-06, 19:33
[No subject] - by bobo1on1 - 2012-03-06, 20:44
[No subject] - by Memphiz - 2012-03-07, 00:28
[No subject] - by beta-j - 2012-03-07, 21:28
[No subject] - by beta-j - 2012-03-07, 21:28
[No subject] - by bobo1on1 - 2012-03-07, 21:31
[No subject] - by beta-j - 2012-03-07, 21:36
[No subject] - by beta-j - 2012-03-09, 18:01
[No subject] - by smajor - 2012-03-09, 18:26
[No subject] - by bobo1on1 - 2012-03-09, 18:32
[No subject] - by regnets - 2012-03-09, 21:26
[No subject] - by beta-j - 2012-03-10, 12:08
RE: - by smajor - 2012-03-13, 11:27
RE: - by phil65 - 2012-03-13, 11:48
RE: - by George - 2012-03-13, 16:29
RE: - by phil65 - 2012-03-13, 16:54
RE: - by George - 2012-03-13, 19:47
Make/Install Errors - by BluechipJ - 2013-04-01, 02:29
RE: [RELEASE] Official XBMC boblight Addon - by Jazzik - 2015-01-11, 02:06
Boblight preset values - by miraclemaker - 2014-05-11, 13:32


Logout Mark Read Team Forum Stats Members Help
[RELEASE] Official XBMC boblight Addon3
This forum uses Lukasz Tkacz MyBB addons.