WS2811 and ATTiny85?

fungus:
I know the code works, I just copy-pasted it from above and ran it.

The only obvious thing I can think of is you're not running at 8MHz. Did you do a 'burn bootloader'?

To be truthful: No, I forgot about that, and tried it.
But sadly, the LED did not light a bit... :/..

Update: IT DID! It does work, I did had a problem with the polarity of the LED.
Yeah, that is really an dumb error - but now it does seem to work for one LED - I will try to work from that...
Thanks a lot!!

Can you measure the voltage on pin 7 of the WS2811 on your board?

According to the datasheet that pin sets the clock speed, if it's been pulled high the data timing changes.

fungus:
Can you measure the voltage on pin 7 of the WS2811 on your board?

According to the datasheet that pin sets the clock speed, if it's been pulled high the data timing changes.

Yeah, I read that too, but - sorry, I think I really missed that out, that baby is now glowing :)!
I think the leason learned here would be:
a) Burn the bootloader to get it to 8 MHz. Do it two times if you're unsure
b) Watch out for the polarity of your LEDs. It is quite easy in dark rooms to mess with the "thought-to-be-longest" pin (it was bend, and therefore I missed the correct one... I'm so damn stupid ~.~!)

Thank you for your time, I think it should work out from here :)!
You were an awesome help!

OK, now you need some of these... :slight_smile:

http://arduino.cc/forum/index.php/topic,148155.0.html

thanks a lot! this saved my butt!

Adafruit's neoPixel code suggests an attiny85 running at 16.5Mhz... but it didn't work for me after a few hours of learning about boards.txt...

ws2811

I did have to use the Burn Bootloader under the Tools Menu for whatever reason when programming with the Arduino as ISP.

I was testing with 2 LEDS and found the flashing of the first LED. I moved the cli / sei... Example..
// Where the WS2811 is attached (pin B4)
#define LED_BIT (1<<4)
#define LED_DDR DDRB
#define LED_PORT PORTB
#define LED_PIN PINB
#define NOP asm("nop\n\t")
int maxColorArr = 256;
int maxColorValue = 255;

class WS2811 {
public:
static void init() {
LED_PORT &= ~LED_BIT;
LED_DDR |= LED_BIT;
}
};
WS2811 ws2811;

// A single LED in the string
class LED {
byte r_,g_,b_;
static void sendByte(byte b) {
byte mask = 0x80;
while (mask!=0) {
if ((b&mask)==0) {
// Send a '0'
LED_PIN = LED_BIT; // Hi (start)
NOP; // Hi
LED_PIN = LED_BIT; // Lo (250ns)
NOP; // Lo
NOP; // Lo (500ns)
NOP; // Lo (data bit here!)
NOP; // Lo (750ns)
NOP; // Lo (875ns)
}
else {
// Send a '1'
LED_PIN = LED_BIT; // Hi (start)
NOP; // Hi
NOP; // Hi (250ns)
NOP; // Hi
NOP; // Hi (500ns)
NOP; // Hi (data bit here!)
NOP; // Hi (750ns)
LED_PIN = LED_BIT; // Lo (875ns)
}
mask >>= 1; // Lo (1000ns)
}
}
public:
// Set my color
LED& setColor(byte r, byte g, byte b) {
r_ = r;
g_ = g;
b_ = b;
}
// Send me to the LED
void send() const {
sendByte(g_);
sendByte(b_);
sendByte(r_);
}
};

LED led1;
LED led2;

void setup()
{
ws2811.init();
}

void getRGBFromIndex(byte colorIndex,byte *ValueR,byte *ValueG,byte *ValueB)
{
if (colorIndex < 43)
*ValueR = 255;
else
if (colorIndex < 86)
*ValueR = 255-(colorIndex * 6);
else
if (colorIndex < 171)
*ValueR = 0;
else
if (colorIndex < 214)
*ValueR = colorIndex * 6;
else
*ValueR = 255;

if (colorIndex < 43)
*ValueG = colorIndex * 6;
else
if (colorIndex < 129)
*ValueG = 255;
else
if (colorIndex < 171)
*ValueG = 255-(colorIndex * 6);
else
*ValueG = 0;

if (colorIndex < 86)
*ValueB = 0;
else
if (colorIndex < 128)
*ValueB = colorIndex * 6;
else
if (colorIndex < 214)
*ValueB = 255;
else
*ValueB = 255-(colorIndex * 6);
}

byte AutoColorIndex1 = 0;
byte AutoColorIndex2 = 128;
// The current RGB color values for mode 3 fade
static byte ValueR1;
static byte ValueG1;
static byte ValueB1;
static byte ValueR2;
static byte ValueG2;
static byte ValueB2;

void loop()
{

getRGBFromIndex(AutoColorIndex1,&ValueR1,&ValueG1,&ValueB1);
AutoColorIndex1++;
if (AutoColorIndex1 == maxColorArr)
AutoColorIndex1 = 0;

getRGBFromIndex(AutoColorIndex2,&ValueR2,&ValueG2,&ValueB2);
AutoColorIndex2++;
if (AutoColorIndex2 == maxColorArr)
AutoColorIndex2 = 0;

led1.setColor(ValueR1,ValueG1,ValueB1);
led2.setColor(ValueR2,ValueG2,ValueB2);

LED_PIN = 0; // Hi (start)

cli(); // Interrupts have to be off while we do this as they cause timing glitches
led1.send();
led2.send();
sei();

delay(100);

/*
byte b = 128;
led.setColor(b,0,b);
led.send();
led.setColor(0,b,0);
led.send();
delay(500);

led.setColor(0,b,0);
led.send();
led.setColor(b,0,b);
led.send();
delay(500);
*/

}

plctim:
I was testing with 2 LEDS and found the flashing of the first LED. I moved the cli / sei... Example..

Yes. Since I wrote that I found out it's best to disable interrupts for the entire send.

Any idea how to get this working with the 800khz WS2812s?

I've got tons of them, and no matter what I try I can't get the adafruit neopixel code to compile for the tiny85, but this code works great (with the old generation pixels)

I'm trying to get it working with the new gen ones too, but can't figure out the changes that are needed for the faster timing

Hi Nico,

Did you finish this project ? I'm trying to do exactly the same thing (i.e. controlling remotely WS2811 led strips with music) but i'm not finding any informations on that. However, I'm less regarding in the cost so I could go on more expensive setups (jeenode ?)

I would be very interested to know how you did that.

I am going to combine this with nrf24l01 radio modules and make it part of my DMX tx/rx system

http://forum.arduino.cc/index.php?topic=208648.msg1817569#msg1817569

I have been looking to do this for sometime, and with using the nrf2401 with an ATTin85 there is only one pin left to use (apart from reset) it seems perfect to use it to drive WS2801's

I am thinking of putting just 3 WS2811 together wired to do the same colours etc, so that my little box becomes a completely wireless, battery operated, 24million colour RGB pixel !! I also got waterproofboxes to so I can put them outside if I want to !!

mcnobby:
I have been looking to do this for sometime, and with using the nrf2401 with an ATTin85 there is only one pin left to use

How did you connect a nrf2401 with only 4 pins?

I am trying to get a fix from this on another thread, but essentially I was going down this route...

http://cratel.wichita.edu/blogs/eecsfinalreportspr2013homeautoframework/assembly/

This person has connected CE from the nrf to ground so that it is always in receive mode - I dont know if this works or not

mcnobby:
This person has connected CE from the nrf to ground so that it is always in receive mode - I dont know if this works or not

It definitely won't work if you connect it to GND. That would lock it in standby-I mode.

It might work if you connect it HIGH and you only ever need receive mode. I never tried it ... (maybe I should)

PS: 6V to power the Tiny85?

There's a lot of very suspect things on that page.

I know, I would like to get to the bottom of this ATTiny85 spare pin thing, I have a serious application :slight_smile:

I also found this... Nerd Ralph: nrf24l01+ control with 3 ATtiny85 pins which only uses 3 lines to drive a nrf24l01 from a ATtiny85.. worth a read I think.. and possibly a few experiments !!

:slight_smile:

mcnobby:
I also found this... Nerd Ralph: nrf24l01+ control with 3 ATtiny85 pins which only uses 3 lines to drive a nrf24l01 from a ATtiny85.. worth a read I think.. and possibly a few experiments !!

3 pins....plus a load of external components.

If you're going to do that you might as well use a Tiny84. It'll be smaller overall and you'll have more pins left over.

one resistor. one diode, one cap... I dont need the LED as I am running from 3.3-3.6v

Thats NOT 'loads' of external components to me :drooling_face:

mcnobby:
one resistor. one diode, one cap... I dont need the LED as I am running from 3.3-3.6v

Thats NOT 'loads' of external components to me :drooling_face:

Well, OK, not "loads"...