ambilight does not work ..

hello friends

I have been working since Saturday at my ambilight. Unfortunately it does not work yet :frowning:

I have a arduino uno r3 and these LEDS:

http://www.ebay.de/itm/171704148171?_trksid=p2060353.m2749.l2649&ssPageName=STRK%3AMEBIDX%3AIT

The power cables are all ok, checked several times. When I click on the arduino upload the LEDstream, it shines in the 3 colors.

But afterwards, when I open Ambibox they splutter around.

I have now found another code with which it is to go:

    // Slightly modified Adalight protocol implementation that uses FastLED
    // library (http://fastled.io) for driving WS2811/WS2812 led stripe
    // Was tested only with Prismatik software from Lightpack project (version 5.9.1, 5.9.6 and 5.11.1 so far - 5.11.1 has some issues on startup in windows so I'm not using it)
     
    #include "FastLED.h"
     
    #define NUM_LEDS 100 // Max LED count
    #define LED_PIN 11 // arduino output pin - probably not required for WS2801
    #define GROUND_PIN 10 // probably not required for WS2801
    #define BRIGHTNESS 96 // maximum brightness
    #define SPEED 115200 // virtual serial port speed, must be the same in boblight_config
     
    CRGB leds[NUM_LEDS];
    uint8_t * ledsRaw = (uint8_t *)leds;
     
    // A 'magic word' (along with LED count & checksum) precedes each block
    // of LED data; this assists the microcontroller in syncing up with the
    // host-side software and properly issuing the latch (host I/O is
    // likely buffered, making usleep() unreliable for latch).  You may see
    // an initial glitchy frame or two until the two come into alignment.
    // The magic word can be whatever sequence you like, but each character
    // should be unique, and frequent pixel values like 0 and 255 are
    // avoided -- fewer false positives.  The host software will need to
    // generate a compatible header: immediately following the magic word
    // are three bytes: a 16-bit count of the number of LEDs (high byte
    // first) followed by a simple checksum value (high byte XOR low byte
    // XOR 0x55).  LED data follows, 3 bytes per LED, in order R, G, B,
    // where 0 = off and 255 = max brightness.
     
    static const uint8_t magic[] = {'A','d','a'};
    #define MAGICSIZE  sizeof(magic)
    #define HEADERSIZE (MAGICSIZE + 3)
     
    #define MODE_HEADER 0
    #define MODE_DATA   2
     
    // If no serial data is received for a while, the LEDs are shut off
    // automatically.  This avoids the annoying "stuck pixel" look when
    // quitting LED display programs on the host computer.
    static const unsigned long serialTimeout = 150000; // 150 seconds
     
    void setup()
    {
      // pinMode(GROUND_PIN, OUTPUT);
      // digitalWrite(GROUND_PIN, LOW);
      // FastLED.addLeds<WS2811, LED_PIN, BRG>(leds, NUM_LEDS);
      FastLED.addLeds<WS2801, RGB>(leds, NUM_LEDS);
     
      // Dirty trick: the circular buffer for serial data is 256 bytes,
      // and the "in" and "out" indices are unsigned 8-bit types -- this
      // much simplifies the cases where in/out need to "wrap around" the
      // beginning/end of the buffer.  Otherwise there'd be a ton of bit-
      // masking and/or conditional code every time one of these indices
      // needs to change, slowing things down tremendously.
      uint8_t
        buffer[256],
        indexIn       = 0,
        indexOut      = 0,
        mode          = MODE_HEADER,
        hi, lo, chk, i, spiFlag;
      int16_t
        bytesBuffered = 0,
        hold          = 0,
        c;
      int32_t
        bytesRemaining;
      unsigned long
        startTime,
        lastByteTime,
        lastAckTime,
        t;
      int32_t outPos = 0;
     
      Serial.begin(SPEED); // Teensy/32u4 disregards baud rate; is OK!
     
      Serial.print("Ada\n"); // Send ACK string to host
     
      startTime    = micros();
      lastByteTime = lastAckTime = millis();
     
      // loop() is avoided as even that small bit of function overhead
      // has a measurable impact on this code's overall throughput.
     
      for(;;) {
     
        // Implementation is a simple finite-state machine.
        // Regardless of mode, check for serial input each time:
        t = millis();
        if((bytesBuffered < 256) && ((c = Serial.read()) >= 0)) {
          buffer[indexIn++] = c;
          bytesBuffered++;
          lastByteTime = lastAckTime = t; // Reset timeout counters
        } else {
          // No data received.  If this persists, send an ACK packet
          // to host once every second to alert it to our presence.
          if((t - lastAckTime) > 1000) {
            Serial.print("Ada\n"); // Send ACK string to host
            lastAckTime = t; // Reset counter
          }
          // If no data received for an extended time, turn off all LEDs.
          if((t - lastByteTime) > serialTimeout) {
            memset(leds, 0,  NUM_LEDS * sizeof(struct CRGB)); //filling Led array by zeroes
            FastLED.show();
            lastByteTime = t; // Reset counter
          }
        }
     
        switch(mode) {
     
         case MODE_HEADER:
     
          // In header-seeking mode.  Is there enough data to check?
          if(bytesBuffered >= HEADERSIZE) {
            // Indeed.  Check for a 'magic word' match.
            for(i=0; (i<MAGICSIZE) && (buffer[indexOut++] == magic[i++]););
            if(i == MAGICSIZE) {
              // Magic word matches.  Now how about the checksum?
              hi  = buffer[indexOut++];
              lo  = buffer[indexOut++];
              chk = buffer[indexOut++];
              if(chk == (hi ^ lo ^ 0x55)) {
                // Checksum looks valid.  Get 16-bit LED count, add 1
                // (# LEDs is always > 0) and multiply by 3 for R,G,B.
                bytesRemaining = 3L * (256L * (long)hi + (long)lo + 1L);
                bytesBuffered -= 3;
                outPos = 0;
                memset(leds, 0,  NUM_LEDS * sizeof(struct CRGB));
                mode           = MODE_DATA; // Proceed to latch wait mode
              } else {
                // Checksum didn't match; search resumes after magic word.
                indexOut  -= 3; // Rewind
              }
            } // else no header match.  Resume at first mismatched byte.
            bytesBuffered -= i;
          }
          break;
     
         case MODE_DATA:
     
          if(bytesRemaining > 0) {
            if(bytesBuffered > 0) {
              if (outPos < sizeof(leds))
                ledsRaw[outPos++] = buffer[indexOut++];   // Issue next byte
              bytesBuffered--;
              bytesRemaining--;
            }
            // If serial buffer is threatening to underrun, start
            // introducing progressively longer pauses to allow more
            // data to arrive (up to a point).
          } else {
            // End of data -- issue latch:
            startTime  = micros();
            mode       = MODE_HEADER; // Begin next header search
            FastLED.show();
          }
        } // end switch
      } // end for(;;)
    }
     
    void loop()
    {
      // Not used.  See note in setup() function.
    }

only I can not upload to, there is always an error.

I've read that one the line: Groundpin and the LED PPIN

still needs to change. just what is the name of the arduino?

am grateful for any help, still rotating through :slight_smile:

regards

That code produces the error:-

sketch_apr29a.ino:5:25: error: FastLED.h: No such file or directory

Which is saying you have not installed the FastLED library.

You can find it here:-

hii

Thank you. I've now done.

but unfortunately now lights up the color when you start wrong, it lights up in blue, green, blue.

as I previously installed the normal LEDstream, it went right. ie red green blue.

I use the software ambibox. there I put on RGB.

it may be that it is the wrong code? So the FastLED?

the seller sent me the name: World semi Preliminary WS2801

the LED also react slowly, the sensitivity I have to maximum.

Thanks for the help :slight_smile:

but unfortunately now lights up the color when you start wrong, it lights up in blue, green, blue.

I have noticed that the red and green colours are swapped over from the surface mount LEDs when you use through hole devices like you have. The software might have been written assuming you had surface mount LEDs.

I own these LEDs:

What do you mean that software could be written ?

it means this is the wrong code ?

The software might have been written assuming you had surface mount LEDs.

Means the software you have, what ever it is because you have not posted it. Might have been written for surface mount LEDs and not the LEDs you have.

I use the software ambibox

The LEDs are not as fast and lag behind the picture ... I order my original from Adafruit . then they certainly work :slight_smile:

waffi:
I own these LEDs:

I have a bunch of those (from eBay, but not the same supplier), strung up over my window for well over a year now - perhaps it is time I put them away; they are too distracting to run. They require one or two Amps at 5V regulated.

There is nothing wrong with them. Of course you need to find the correct code - I do use the appropriate code (including the library) from Adafruit which works just fine. Whether this is the same as or compatible with the "ambilight" code I do not know. I would suggest you find the matching devices in Adafruit's listing and start by experimenting with the code they offer.

Thank you . have a link to the various code ? I have only the fastled code found .

in another forum I have found someone who had the same problem . he took this code:

    // Slightly modified Adalight protocol implementation that uses FastLED
    // library (http://fastled.io) for driving WS2811/WS2812 led stripe
    // Was tested only with Prismatik software from Lightpack project (version 5.9.1, 5.9.6 and 5.11.1 so far - 5.11.1 has some issues on startup in windows so I'm not using it)
     
    #include "FastLED.h"
     
    #define NUM_LEDS 100 // Max LED count
    #define LED_PIN 11 // arduino output pin - probably not required for WS2801
    #define GROUND_PIN 10 // probably not required for WS2801
    #define BRIGHTNESS 96 // maximum brightness
    #define SPEED 115200 // virtual serial port speed, must be the same in boblight_config
     
    CRGB leds[NUM_LEDS];
    uint8_t * ledsRaw = (uint8_t *)leds;
     
    // A 'magic word' (along with LED count & checksum) precedes each block
    // of LED data; this assists the microcontroller in syncing up with the
    // host-side software and properly issuing the latch (host I/O is
    // likely buffered, making usleep() unreliable for latch).  You may see
    // an initial glitchy frame or two until the two come into alignment.
    // The magic word can be whatever sequence you like, but each character
    // should be unique, and frequent pixel values like 0 and 255 are
    // avoided -- fewer false positives.  The host software will need to
    // generate a compatible header: immediately following the magic word
    // are three bytes: a 16-bit count of the number of LEDs (high byte
    // first) followed by a simple checksum value (high byte XOR low byte
    // XOR 0x55).  LED data follows, 3 bytes per LED, in order R, G, B,
    // where 0 = off and 255 = max brightness.
     
    static const uint8_t magic[] = {'A','d','a'};
    #define MAGICSIZE  sizeof(magic)
    #define HEADERSIZE (MAGICSIZE + 3)
     
    #define MODE_HEADER 0
    #define MODE_DATA   2
     
    // If no serial data is received for a while, the LEDs are shut off
    // automatically.  This avoids the annoying "stuck pixel" look when
    // quitting LED display programs on the host computer.
    static const unsigned long serialTimeout = 150000; // 150 seconds
     
    void setup()
    {
      // pinMode(GROUND_PIN, OUTPUT);
      // digitalWrite(GROUND_PIN, LOW);
      // FastLED.addLeds<WS2811, LED_PIN, BRG>(leds, NUM_LEDS);
      FastLED.addLeds<WS2801, RGB>(leds, NUM_LEDS);
     
      // Dirty trick: the circular buffer for serial data is 256 bytes,
      // and the "in" and "out" indices are unsigned 8-bit types -- this
      // much simplifies the cases where in/out need to "wrap around" the
      // beginning/end of the buffer.  Otherwise there'd be a ton of bit-
      // masking and/or conditional code every time one of these indices
      // needs to change, slowing things down tremendously.
      uint8_t
        buffer[256],
        indexIn       = 0,
        indexOut      = 0,
        mode          = MODE_HEADER,
        hi, lo, chk, i, spiFlag;
      int16_t
        bytesBuffered = 0,
        hold          = 0,
        c;
      int32_t
        bytesRemaining;
      unsigned long
        startTime,
        lastByteTime,
        lastAckTime,
        t;
      int32_t outPos = 0;
     
      Serial.begin(SPEED); // Teensy/32u4 disregards baud rate; is OK!
     
      Serial.print("Ada\n"); // Send ACK string to host
     
      startTime    = micros();
      lastByteTime = lastAckTime = millis();
     
      // loop() is avoided as even that small bit of function overhead
      // has a measurable impact on this code's overall throughput.
     
      for(;;) {
     
        // Implementation is a simple finite-state machine.
        // Regardless of mode, check for serial input each time:
        t = millis();
        if((bytesBuffered < 256) && ((c = Serial.read()) >= 0)) {
          buffer[indexIn++] = c;
          bytesBuffered++;
          lastByteTime = lastAckTime = t; // Reset timeout counters
        } else {
          // No data received.  If this persists, send an ACK packet
          // to host once every second to alert it to our presence.
          if((t - lastAckTime) > 1000) {
            Serial.print("Ada\n"); // Send ACK string to host
            lastAckTime = t; // Reset counter
          }
          // If no data received for an extended time, turn off all LEDs.
          if((t - lastByteTime) > serialTimeout) {
            memset(leds, 0,  NUM_LEDS * sizeof(struct CRGB)); //filling Led array by zeroes
            FastLED.show();
            lastByteTime = t; // Reset counter
          }
        }
     
        switch(mode) {
     
         case MODE_HEADER:
     
          // In header-seeking mode.  Is there enough data to check?
          if(bytesBuffered >= HEADERSIZE) {
            // Indeed.  Check for a 'magic word' match.
            for(i=0; (i<MAGICSIZE) && (buffer[indexOut++] == magic[i++]););
            if(i == MAGICSIZE) {
              // Magic word matches.  Now how about the checksum?
              hi  = buffer[indexOut++];
              lo  = buffer[indexOut++];
              chk = buffer[indexOut++];
              if(chk == (hi ^ lo ^ 0x55)) {
                // Checksum looks valid.  Get 16-bit LED count, add 1
                // (# LEDs is always > 0) and multiply by 3 for R,G,B.
                bytesRemaining = 3L * (256L * (long)hi + (long)lo + 1L);
                bytesBuffered -= 3;
                outPos = 0;
                memset(leds, 0,  NUM_LEDS * sizeof(struct CRGB));
                mode           = MODE_DATA; // Proceed to latch wait mode
              } else {
                // Checksum didn't match; search resumes after magic word.
                indexOut  -= 3; // Rewind
              }
            } // else no header match.  Resume at first mismatched byte.
            bytesBuffered -= i;
          }
          break;
     
         case MODE_DATA:
     
          if(bytesRemaining > 0) {
            if(bytesBuffered > 0) {
              if (outPos < sizeof(leds))
                ledsRaw[outPos++] = buffer[indexOut++];   // Issue next byte
              bytesBuffered--;
              bytesRemaining--;
            }
            // If serial buffer is threatening to underrun, start
            // introducing progressively longer pauses to allow more
            // data to arrive (up to a point).
          } else {
            // End of data -- issue latch:
            startTime  = micros();
            mode       = MODE_HEADER; // Begin next header search
            FastLED.show();
          }
        } // end switch
      } // end for(;;)
    }
     
    void loop()
    {
      // Not used.  See note in setup() function.
    }

only that he has changed the line with the Groundpin and the LED PPIN .

Can you tell me what I paid as required to enter ? I do not find it unfortunately :frowning:

Thank you!

That code - and the references to "Fastled" - looks quite wrong to me.

The WS2801 - as you illustrate - uses two wires to control the chain, the WS2811/2812 uses only one control line. They are completely different systems and there is virtually nothing in common between the code for operating each.

This would appear to be the reference for the correct library and examples.

Alright ..

So it would be the greadtest.pde because I have to take ?

The beach will be the test or false ? otherwise he has no PDE files ?

Thanks for the help :slight_smile:

I've tried that , unfortunately, that's the wrong code :frowning: The seller gave me the name sent : Preliminary WS2801 world semi

under google I find even under Adafruit the datasheet :

only I think, unfortunately, no more fitting end code :frowning:

So here's a test video from YouTube , there react the colors quickly ..

and here is a video of me :

the LEDs but about 1 second to be late ? and the colors also agree not .. I've already tried every setting in ambibox , remains the same :frowning:

Well, this code works for me as a starter:

#include "SPI.h"
#include "Adafruit_WS2801.h"

/*****************************************************************************
Example sketch for driving Adafruit WS2801 pixels!


  Designed specifically to work with the Adafruit RGB Pixels!
  12mm Bullet shape ----> https://www.adafruit.com/products/322
  12mm Flat shape   ----> https://www.adafruit.com/products/738
  36mm Square shape ----> https://www.adafruit.com/products/683

  These pixels use SPI to transmit the color data, and have built in
  high speed PWM drivers for 24 bit color per pixel
  2 pins are required to interface

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

  Written by Limor Fried/Ladyada for Adafruit Industries.  
  BSD license, all text above must be included in any redistribution

*****************************************************************************/

// Choose which 2 pins you will use for output.
// Can be any valid output pins.
// The colors of the wires may be totally different so
// BE SURE TO CHECK YOUR PIXELS TO SEE WHICH WIRES TO USE!
uint8_t dataPin  = 6;    // Yellow wire on Adafruit Pixels
uint8_t clockPin = 7;    // Green wire on Adafruit Pixels

// Don't forget to connect the ground wire to Arduino ground,
// and the +5V wire to a +5V supply

// Set the first variable to the NUMBER of pixels. 25 = 25 pixels in a row
Adafruit_WS2801 strip = Adafruit_WS2801(25, dataPin, clockPin);

// Optional: leave off pin numbers to use hardware SPI
// (pinout is then specific to each board and can't be changed)
//Adafruit_WS2801 strip = Adafruit_WS2801(25);

// For 36mm LED pixels: these pixels internally represent color in a
// different format.  Either of the above constructors can accept an
// optional extra parameter: WS2801_RGB is 'conventional' RGB order
// WS2801_GRB is the GRB order required by the 36mm pixels.  Other
// than this parameter, your code does not need to do anything different;
// the library will handle the format change.  Examples:
//Adafruit_WS2801 strip = Adafruit_WS2801(25, dataPin, clockPin, WS2801_GRB);
//Adafruit_WS2801 strip = Adafruit_WS2801(25, WS2801_GRB);

void setup() {
    
  strip.begin();

  // Update LED contents, to start they are all 'off'
  strip.show();
}


void loop() {
  // Some example procedures showing how to display to the pixels
  
  colorWipe(Color(255, 0, 0), 50);
  colorWipe(Color(0, 255, 0), 50);
  colorWipe(Color(0, 0, 255), 50);
  rainbow(20);
  rainbowCycle(20);
}

void rainbow(uint8_t wait) {
  int i, j;
   
  for (j=0; j < 256; j++) {     // 3 cycles of all 256 colors in the wheel
    for (i=0; i < strip.numPixels(); i++) {
      strip.setPixelColor(i, Wheel( (i + j) % 255));
    }  
    strip.show();   // write all the pixels out
    delay(wait);
  }
}

// Slightly different, this one makes the rainbow wheel equally distributed 
// along the chain
void rainbowCycle(uint8_t wait) {
  int i, j;
  
  for (j=0; j < 256 * 5; j++) {     // 5 cycles of all 25 colors in the wheel
    for (i=0; i < strip.numPixels(); i++) {
      // tricky math! we use each pixel as a fraction of the full 96-color wheel
      // (thats the i / strip.numPixels() part)
      // Then add in j which makes the colors go around per pixel
      // the % 96 is to make the wheel cycle around
      strip.setPixelColor(i, Wheel( ((i * 256 / strip.numPixels()) + j) % 256) );
    }  
    strip.show();   // write all the pixels out
    delay(wait);
  }
}

// fill the dots one after the other with said color
// good for testing purposes
void colorWipe(uint32_t c, uint8_t wait) {
  int i;
  
  for (i=0; i < strip.numPixels(); i++) {
      strip.setPixelColor(i, c);
      strip.show();
      delay(wait);
  }
}

/* Helper functions */

// Create a 24 bit color value from R,G,B
uint32_t Color(byte r, byte g, byte b)
{
  uint32_t c;
  c = r;
  c <<= 8;
  c |= g;
  c <<= 8;
  c |= b;
  return c;
}

//Input a value 0 to 255 to get a color value.
//The colours are a transition r - g -b - back to r
uint32_t Wheel(byte WheelPos)
{
  if (WheelPos < 85) {
   return Color(WheelPos * 3, 255 - WheelPos * 3, 0);
  } else if (WheelPos < 170) {
   WheelPos -= 85;
   return Color(255 - WheelPos * 3, 0, WheelPos * 3);
  } else {
   WheelPos -= 170; 
   return Color(0, WheelPos * 3, 255 - WheelPos * 3);
  }
}

I have the library in my ~/sketchbook/libraries/WS2801 containing

-rw-rw-r--. 1 paulb paulb 7703 Mar 15  2013 Adafruit_WS2801.cpp
-rw-rw-r--. 1 paulb paulb 2184 Mar 15  2013 Adafruit_WS2801.h
drwx------. 4 paulb paulb 4096 Feb  5  2014 examples
-rw-rw-r--. 1 paulb paulb 1171 Mar 15  2013 README.txt

and "examples" contains:

drwx------. 2 paulb paulb 4096 Feb  5  2014 gridtest
drwx------. 2 paulb paulb 4096 Feb  5  2014 strandtest

of which "strandtest" is the code I cite above, or was before I played with it to suit my particular system.

I suggest to you that if you have that library correctly installed, you should be able to run the test code and from there, modify it to suit your purpose.

Unfortunately not ... have it made ​​exactly upload went on airduino . but it flakert again ..

the fastled taken back lit , back .. I 'll give it to .. buy me the original by Adafruit .

regards

If you tried that code, did you connect these or alter the code to suit your connections?

uint8_t dataPin  = 6;    // Yellow wire on Adafruit Pixels
uint8_t clockPin = 7;    // Green wire on Adafruit Pixels

And did you try swapping the two control wires?

Now it is even funnier .. forgot the clock and pin number to change . now light up LEDs , only the first 30 and the color comes from the United side to the other . ambibox reacts to nothing .

wires I have also exchanged ..